• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Waez Ali
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • 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 ]
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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.
 
Sivakumar Janardhanan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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: 56578
172
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!