File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Date class question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date class question" Watch "Date class question" New topic

Date class question

Rebecca Pickett

Joined: Aug 16, 2000
Posts: 15
When I create a new java.util.Date class object with a long parameter, I should get this according to all the documentation I've read:
January 1, 1970, 00:00:00 GMT
BUT, I'm getting December 31, 1969, 18:00:00 CST when I print it out. Is this time-zone compensation normal??
tony hutcheson
Ranch Hand

Joined: Dec 08, 2000
Posts: 38
I have a guess. Do you live in the Central time zone? Because
January 1, 1970, 00:00:00 GMT
is the same as
December 31, 1969, 18:00:00 CST
It then adjusted for the time zone on your computer.
Hope that helps.
Rebecca Pickett

Joined: Aug 16, 2000
Posts: 15
Yep, sure do and that's what I figured it was doing.
I was just surprised that it was compensating for Time Zone and not giving the real "epoch" in GMT.
Janna Lockhart

Joined: Dec 21, 2000
Posts: 24
It's part of the portability of Java that it adjusts for the time zone that you're in. Notice the time stamps here at the java ranch on our posts? They accurately display the time stamp according to your time zone rather than the time zone of each user so that it's a more accurate view of the relative timing of each post!

- Janna
Rebecca Pickett

Joined: Aug 16, 2000
Posts: 15
Well that makes perfect sense, java portability-wise. Thanks for helping me see the light!
I agree. Here's the link:
subject: Date class question
Similar Threads
Time conversion question
convert datetime from EST to PST
Joda DateTime
dynamically expand and collapse table rows
SEVERE: BAD packet signature 200,SEVERE: Caught exception (java.lang.NullPointerException)