This week's book giveaway is in the Functional programming forum.
We're giving away four copies of A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles and have Ben Weidig on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

UTC or GMT for Date( ) constructor with no arg.

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have some doubt about the Date() constructor, the spcification says

Date()

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Is it creating Date in UTC format or GMT formate ?

Or does it depend on the current Locale ?

Please explain.

Thanks in Advance.
[ December 18, 2008: Message edited by: Waez Ali ]
 
Marshal
Posts: 77943
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what it says in the API the answer appears to be "no to all." Read the link; it tells you what is stored. I presume that is the correct Date class; there are two.

You might be better to use GregorianCalendar.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi waez, i think the Date class is intended to reflect coordinated universal time (UTC), it may not do so exactly, depending on the host environment of the Java Virtual Machine. Nearly all modern operating systems assume that 1�day�= 24���60���60�= 86400 seconds in all cases.

Normally system assume 1 seconds = 10 milli seconds. so i think date object is taking the UTC format.
 
Campbell Ritchie
Marshal
Posts: 77943
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows might have 10 milliseconds to the second, but I always use 1000.

Actually, I think the java.util.Date class field is not time-zone dependent. It records how many milliseconds there have been since a time the same as 00:00:00.000 1st January 1970 in GMT, and it has to be corrected for local time-zones.

Actually we didn't use GMT that Winter in Britain, so the time represented was actually 1am here. And nobody knew it was the "epoch" since that time hadn't been decided yet!
 
reply
    Bookmark Topic Watch Topic
  • New Topic