Re: Storing Java Timestamp (long) in database as BIGINT?
Posted by:
Rick James
Date: November 25, 2010 02:10PM
Java time is in milliseconds, correct? There are several ways to store it.
This is popular:
BIGINT and store milliseconds since start of epoch. -- 8 bytes
This is what I prefer (for any hi-res datetime):
DOUBLE, with the decimal point positioned so that one unit = one second. -- 8 bytes
cf Perl's Time::HiRes and PHP's microtime(true)
This would be slightly smaller for Java's flavor of time:
DECIMAL(13, 0) -- storing milliseconds -- 6 bytes
DECIMAL(13, 3) -- 1 unit = 1 sec. -- 7 bytes
(The implementation of DECIMAL changed at some point; the sizes are for ver. 5.1.30).
I prefer to have 1 unit = 1 second as rule everywhere; that way I won't forget to multiply/divide by 1000 or 86400.
Subject
Written By
Posted
November 24, 2010 11:19AM
Re: Storing Java Timestamp (long) in database as BIGINT?
November 25, 2010 02:10PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.