File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date class related query" Watch "Date class related query" New topic

Date class related query

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055 || 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

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

Joined: Oct 27, 2005
Posts: 19755

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

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Date class related query