Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Data

 
Lukasz Szwed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lukasz !!!

Take a look to the javadoc of the Date class.



Hope it help.
 
Lukasz Szwed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you...

That's clear enough.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic