In my last post, I described an XML over HTTP service written in Java that I have to integrate with. I expressed a minor and general annoyance at the fact that the developers of this service specify that a “DateTime” parameter be specified in “milliseconds since the epoch”.
There is another typical problem with Java services that isn’t always as evident.
When Congress decides to change the Daylight Savings Time switch dates, the JVM typically needs to be patched separately from the OS it is running on. And this never happens.
So, if you are passing a message to a Java service gateway with a parameter like “delivery time” specified in “milliseconds since epoch”, and you think it’s Daylight Savings Time, but the Java service thinks it’s “Standard Time”, then your message will be delivered an hour late.
I usually deal with that case ad-hoc by specifying a variable in a YAML file, like this:
1 | tz-fix: true |
And then in my code like this:
1 2 3 4 | # Read in my config @@c = YAML.load_file(File.join(File.dirname(__FILE__), "myapp.yml")) # ... millis = millis - (60*60*1000) if @@c["tz-fix"] |
If the remote service talks in “seconds since epoch”, I drop the “* 1000″.
Good luck.
Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment