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
http://today.java.net/pub/a/today/2008/09/18/jsr-310-new-java-date-time-api.html
The only other option I can see is to mathematically implement it every time
I need to look up a record.
E.g.
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.
No you can’t, and it would be a bad idea if you could. Every timestamp in your database is going to use the same space, regardless of how big the number is. (Assuming you are storing the number as a number and not as a string or something.)
Now, if you really want this, you’ll have to write it yourself. I.e. subtract the time from your timestamps before putting them into the database, and add the time to the timestamps when you get them back out. But this is asking for maintenance problems. (In fact, using timestamps instead of the database’s native DATETIME datatype is asking for problems.)