This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date class related query

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohamed El-Feky
Greenhorn
Posts: 19
Eclipse IDE Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
absolutely right

you might try to use different constructor to get diff response
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost right. Not 1/1/1970 00:00:02 UTC but 1/1/1970 00:00:00.002 UTC.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic