Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleDateFormat parse() gives incorrect result

Tags:

java

Dfault TimeZone GMT-3.00. I am parsing new Date("1900/01/01").toString using the parse method of SimpleDateFormat.

The Result i get is Sun Dec 31 23:15:16 UYT 1899 instead of Mon Jan 01 00:00:00 UYT 1900

I can't understand why is the result different.

PS: If i change the TimeZone to GMT +5.30 the result is as expected.

like image 902
Preet Avatar asked Aug 16 '11 08:08

Preet


2 Answers

According to UYT timezone changes at timeanddate.com, UYT timezone was UTC-3.44.44 prior to 1920 rather than UTC-3.00, so that your result looks correct.

like image 124
axtavt Avatar answered Oct 23 '22 18:10

axtavt


are you using this code?

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/dd/MM");
    System.out.println(sdf.parse("1900/01/01"));

Maybe you got the wrong symbols...

like image 28
Torres Avatar answered Oct 23 '22 19:10

Torres