Falsches DateFormat isvalid

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Falsches DateFormat isvalid

by Anonymous » 24 Feb 2025, 12:18

Ich mache einen Datumstest < /p>

Code: Select all

  String INCORRECT_DATE_1 = "101.10.2010";
String dtFormatString_104 = "dd.MM.yyyy";

@Test
public void isValidDate() {

FastDateFormat formatter = FastDateFormat.getInstance(dtFormatString_104);

try {
final Date parse = formatter.parse(INCORRECT_DATE_1);
} catch (java.text.ParseException e) {
return false;
}
return true;
}
und ich werden hier wahr, weil Parse 9. Januar 2011 ist. Wie kann ich es richtig validieren? Ich möchte hier aufgrund des Inkorrekturdatums

Top