wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in Data" Watch "Doubt in Data" New topic
Author

Doubt in Data

Lukasz Szwed
Greenhorn

Joined: Oct 11, 2007
Posts: 6
Hi,

I'm brand new in Javarunch.
I've just started to learn for SCJP. I've already found answers for most of my questions here.

Can someone explain me why this code below produce the:
Thu Jan 01 01:00:00 GMT 1970
I thought that the result will be:
Thu Jan 01 00:00:00 GMT 1970


SCJP 5.0, SCJA 1.0,
Next target SCWCD 5.0
Collins Mbianda
Ranch Hand

Joined: Aug 11, 2007
Posts: 259
Hi Lukasz !!!

Take a look to the javadoc of the Date class.



Hope it help.


SCJP 5.0 | SCWCD 1.4
Lukasz Szwed
Greenhorn

Joined: Oct 11, 2007
Posts: 6
Hi,

I did look into documentation before I posted here.

But I don't understand why if I pass 0l (0 long) paramenter, the date is set as a Thu Jan 01 01:00:00 GMT 1970 shouldn't be set as a 00:00:00 ?

As you mentioned, the parameter means: Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

So I'm still confiused, If I pass 0 milliseconds (and from January 1, 1970 00:00:00 GMT past 0 miliseconds) the time should be the same, so why it is 1 hour later?

Please tell me where I am wrong?
Collins Mbianda
Ranch Hand

Joined: Aug 11, 2007
Posts: 259
If i run your code, i will have: Thu Jan 01 01:00:00 CET 1970

This because my Time Zone is CET and CET is 1 hour ahead of GMC.

Are you sure that your Time Zone is GMC ?

Try to format your answer in GMC and see the answer. Use this code;
Lukasz Szwed
Greenhorn

Joined: Oct 11, 2007
Posts: 6
Thank you...

That's clear enough.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Data
 
Similar Threads
epoch is wrong
Date 01/01/1970 returning non-zero value for time
Calendar() / Date() bug ???
Millisecond accuracy
Date class - GeekWatch