I want to be able to change the base millisecond reference from 1970 to 2008 in Java so
that I can save space in the database and unique Ids.
Preferably with Joda-Time.
The upcoming jsr-310 in the supposed Java 7 release implements it.
In the *The Discrete Timeline* section of this link it states that the counting of milliseconds has changed from 1970 to 2008
The only other option I can see is to mathematically implement it every time
I need to look up a record.
DateTime dt = new DateTime();
long now = dt.getMillis();
DateTime dt2 = new DateTime(2008, 1, 1, 0, 0, 0, 0);
long then = dt2.getMillis();
long smallerDate = now - then;
Smaller date will be stored in the DB
-- **Edit** --
So I misread the JSR-310, and it's not possible.
There are better ways to save space and then a headache of
processing thousands of request to calculate longs.
I wanted to record longs as dates because I'll never know where I will move
the DB to, perhaps MySQL => Oracle.
So I didn't want timestamps, I just wanted BigInts.
How is this supposed to save space in the DB? Sure, that text representation of the long value would be slightly shorter, but if you declare the column to be of type bigint (or similar, as you have to in order to store the value), it take the same size regardless of the beginning of the epoch.
以上就是Is it possible to change the base millisecond reference time from 1970 to 2008 in Java (like JSR-310)的详细内容，更多请关注web前端其它相关文章！