Search code examples
javajava-6

GregorianCalendar.getTime() default time is different when date is day light saving day


I have a very strange issue. I am not able to consistently recreate but its happening. So when the date is 04/25/1948, GregorianCalendar.getTime() returns Date as

Sun Apr 25 1:00:00 EDT 1948

I am not sure why it has time of 1:00:00 and not 00:00:00. I am not setting any time in date. Do you guys have any pointers of why it would set time of 1:00:00.

note: I am in EST time zone.

Thanks!


Solution

  • In Sun Apr 25 1:00:00 EDT 1948, EDT indicates it is Eastern Daylight Time and currently your machine is on EST. Hence, you are seeing a difference of 1 hour.

    On April 25 1948, Daylight savings was activated and EST transitioned to EDT.

    For eg. check this to see history of daylight savings changes of Detroit.