On 6/18/2015 11:25 AM, Lukas Eder wrote:
Garret. No one said that date, time and timezones are easy :)
I'm fully versed in date, time, and time zones. I have co-written a
complex time scheduling program which routed appointments of a customer
in one time zone to consultants based upon their local available times
in various time zones around the world.
The System.getCurrentTimeMillis() /is/ in fact easy. It has a
specification. It is internally tied to UTC. It is represented by
java.util.Date and java.time.Instant (Java 8) and org.joda.time.Instant.
It should /always be identical regardless of what time zone you are in/.
It is only when you want to convert that absolute instant to some local
date that you run into problems. But converting to a local time I can
handle. What I want to make sure is that my Date/Instant is stored and
retrieved with no modifications---independent of the time zone of my
database server or my JVM or whatever. This Date/Instant is at its basis
a long integer value---and it never, ever, ever changes!!
Lukas, I'll go read your extensive references, which look entertaining.
:) But in the end, all I want to know is that I the following JUnit
pseudo-code will work:
final long now=System.getCurrentTimeMillis();
final Timestamp before=new Timestamp(now);
...
//create record
jooqRecord.setTimestamp(before);
...
//change JVM time zone to "foo"
//change database time zone to "bar"
//retrieve record
final Timestamp after=jooqRecord.getTimestamp();
assertEqual(before, after); //a timestamp should never, ever change!!
I apologize in advance if you already answered that question---I'm going
to carefully review what you wrote, because you put a lot of time into
writing it. But the last part, "... if you're not operating across time
zones, you're fine ...", makes me very wary. ;)
Thanks again---I'll read everything and get back to you.
Garret
--
You received this message because you are subscribed to the Google Groups "jOOQ User
Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.