Dates

#1

Question on dates.

SQL doesn't seem to store timezone with dates (oddly).

So, any best practises with ODB?

1. use java.util.Date

2. Milliseconds since January 1, 1970, 00:00:00 GMT

3. other?

#2

When a Date instance is stored in an ObjectDB database it is converted automatically to GMT, so in the database all the date and timestamp values are GMT. When the value is retrieved from the database it is automatically converted back to local time.

Using (2) instead of (1) in your option list might be slightly faster because of the overhead of instantiating Date objects (if a Date object is not required - a primitive long field is more efficient), but usually the difference is not significant, so Date values are usually preferred because they represent date and time values better.

If you want to store a timezone you may use a separate int field.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login