views:

58

answers:

1

Hi,
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());
+9  A: 

Try:

"yyyy-MM-dd'T'HH:mm:ss"

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

Mark Byers
Thank you I figured that out.
manu
Welcome to SO, @manu! It sounds like you consider this the correct answer. You can mark it as the accepted answer by clicking the outline of a checkmark above and to the left of this comment. That helps other people see that the question has been answered, gives the answerer +15 rep and gives you +2 rep!
Lord Torgamus
@manu - "Figured it out"? Or read ColinD's comment?
duffymo