Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Doubt in Data

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you...

That's clear enough.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic