Date String Parsing.

Hi all,

I need to parse a date that is input by the user.

I thought to pick the input string and use it to create a Date object by parsing it.

example: here inputString is the String that holds the date.

DateFormat fd =new SimpleDateFormat("dd/MM/yyyy");

try{

Date when = fd.parse(inputString);

}

catch (ParseException pe){

<do something to alert the user>

}

the problem is:

if I input the following string:

50/13/2004

it PARSES GOOD (!!) and the parsed date is

19/02/2005

probably because 13/2004 -> 01/2005 and 50 -> 31 + 19...

any help? Thank you!

[941 byte] By [EllEffCeea] at [2007-10-1 6:16:23]
# 1
fd.setLenient(false);
yawmarka at 2007-7-9 15:10:14 > top of Java-index,Desktop,I18N...
# 2
You'll need to setLenient to false *before* you call parse(), of course...
yawmarka at 2007-7-9 15:10:14 > top of Java-index,Desktop,I18N...