• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does Java time work?

 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic