Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Why both new Date() and Calendar.getInstance give wrong time

807591Mar 11 2008 — edited Mar 11 2008
hi, folks:

I get a strange problem. I am trying to get the current time which is showing on the lower right corner of my computer. I tried new Date() and Calendar.getInstance( ). However, either gives me wrong hour, for example, if the current time is Mar 11, 3:20 PM, 2008, US eastern time, either one gives me: Tue Mar 11 14:20:00 EST 2008, which is always one hour behind the current time, but the month, date, year , minute and time zone are correct.

I also tried new Date((System.currentTimeMillis())) but get the same thing

I further tried new GregorianCalendar().get(Calendar.DST_OFFSET), it should give me 3600000 (one hour) but actually it gived me 0

I thought the Java code should automatically catch the daylight saving time but it is not the case.

I install tzupdater.jar and run but nothing change.

anybody has any idea, I appreciate your kind help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2008
Added on Mar 11 2008
10 comments
928 views