manu manu - 1 year ago 87
Java Question

SimpleDateFormat ignoring month when parsing

The following code is giving me the parsed date as "Wed Jan 13 00:00:00 EST 2010"
instead of "Wed Jun 13 00:00:00 EST 2010". Any ideas much appreciated.

SimpleDateFormat sf = new SimpleDateFormat("yyyy-mm-dd'T'HH:mm:ss");

String str = "2010-06-13T00:00:00";

Date date = sf.parse(str);

System.out.println(" Date " + date.toString());

Answer Source



MM means month. mm means minutes. See the documentation for SimpleDateFormat for more details of the supported date and time patterns.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download