aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How does Java time work?" Watch "How does Java time work?" New topic
Author

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?

Thanks,
Tom
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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?