jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes How does Java time work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How does Java time work?" Watch "How does Java time work?" New topic

How does Java time work?

Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

We were using Java SDK 1.4.2_05 when here in the states we had our early DST(Daylight Saving Time). Our Windows XP machines showed the time correctly (Since they were patched) but when we spit out a Java Date we were an hour behind. I have since updated my SDK (1.4.2_13) to one with a proper DST patch. My question is if the JVM isn't getting time from the machine where the heck does it get it from? Also why does it get from somewhere else than the local machine?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Java does get its date from the local machine. But Java contains its own rules about what timezones exist and when they observe daylight saving time. If Java's rules don't agree with Windows's rules (which is what happened between the two patches) then Java and Windows will interpret and display the current time differently.

Read the API documentation for the java.util.Date class for more information about how Java deals with dates and times, and scroll down until you see it mentioning 1970.
I agree. Here's the link: http://aspose.com/file-tools
subject: How does Java time work?
It's not a secret anymore!