*
The moose likes Beginning Java and the fly likes Date class related query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date class related query" Watch "Date class related query" New topic
Author

Date class related query

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055



http://www.lifesbizzare.blogspot.com || OCJP:81%
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

java.util.Date holds the date as the number of milliseconds since the epoch of 1/1/1970 00:00:00 UTC. The constructor you are using is using the value you provide as this millisecond value so '2' means 1/1/1970 00:00:02 UTC. The toString() method uses your current time zone when converting the milliseconds to a String.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Mohamed El-Feky
Greenhorn

Joined: Jan 14, 2011
Posts: 17

absolutely right

you might try to use different constructor to get diff response


Learn it, Live it, Love it
Java is my passion
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Almost right. Not 1/1/1970 00:00:02 UTC but 1/1/1970 00:00:00.002 UTC.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date class related query
 
Similar Threads
I forgot what is the difference!
test with dependency on current date
How can I get sysdate in java?
Garbage Collection
Immutable Class