This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java date/time long value in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java date/time long value in database" Watch "Java date/time long value in database" New topic

Java date/time long value in database

Martin Coetzee

Joined: Dec 02, 2003
Posts: 21
Hi everyone. Here's my question. We store the java date/time long value in the database as ie: 1173691253612. Another system that's non java needs to read the value, and interpret it as a date. How do you format this value into a date if you don't use java? Is there a special algorithm?
Jeremy Botha
Ranch Hand

Joined: Feb 16, 2005
Posts: 125
Hi, Martin.

The sun API documentation for date states that the long value of Date specifies the number of milliseconds since 01 January 1970, 00:00:00.000 GMT.

You need to ensure that the non-java system you're interfacing with either uses this epoch, or is able to do the conversion between the Java epoch and whatever epoch it operates in.

hope this helps!


McFinnigan? Never heard of him. Nobody here but us chickens...<br /> <br />SCJP for Java 1.4<br />SCJD for Java 5.0
It is sorta covered in the JavaRanch Style Guide.
subject: Java date/time long value in database