Java app with strange timezone behavior

B

Bill Seitz

I've inherited some Java code (plus stuff in other languages), and I'm
not a Java guru.

I just discovered some messed-up behavior of the existing code.

A month back I realized that the server (RedHat) clock was set to CST,
which was not what I wanted. So I changed the system clock and
hardware clock to EST. Data which was getting stuffed into PostgreSQL
by the Java code had the right zone timestamp on it.

But I was digging in more detail into the code the other day, and it
seemed like the data was off by an hour. And when I looked at a log
file that the code was writing, I saw all its timestamps labelled as
CST!

I couldn't find any timezone objects in the code, nor any config stuff
that would explain this behavior.

Could someone give me a hint as to what to look for? (I'll worry next
about the timezone params getting passed to the db insert, but for now
I think just getting the Java code to "think" in the same timezone as
the rest of the server would be nice...)

thx
Bill Seitz
http://webseitz.fluxent.com/wiki
 
R

Ryan Stewart

Bill Seitz said:
I've inherited some Java code (plus stuff in other languages), and I'm
not a Java guru.

I just discovered some messed-up behavior of the existing code.

A month back I realized that the server (RedHat) clock was set to CST,
which was not what I wanted. So I changed the system clock and
hardware clock to EST. Data which was getting stuffed into PostgreSQL
by the Java code had the right zone timestamp on it.

But I was digging in more detail into the code the other day, and it
seemed like the data was off by an hour. And when I looked at a log
file that the code was writing, I saw all its timestamps labelled as
CST!

I couldn't find any timezone objects in the code, nor any config stuff
that would explain this behavior.

Could someone give me a hint as to what to look for? (I'll worry next
about the timezone params getting passed to the db insert, but for now
I think just getting the Java code to "think" in the same timezone as
the rest of the server would be nice...)

thx
Bill Seitz
http://webseitz.fluxent.com/wiki

Maybe look for a DateFormat or SimpleDateFormat object. There's a
setTimeZone method in DateFormat. It's also conceivable that the time zone
was hard coded, like maybe the calculations were done manually instead of
using the Java objects. That could be a little harder to track down if it's
not well-commented. If you already know what code is producing the output,
post it.
 
B

Bill Seitz

Thanks, that looks very promising. One confusion: am I correct in
reading that there's no way to *save* the user.timezone permanently?
So I have to make sure that setting I want is called every time I
launch the JVM?
 
B

Bill Seitz

oy, tt looks like the sysadmin had never restarted the JVM after the
system time was changed. While it looked like the functionality was
triggered by cron jobs, there was an underlying server stub
(JavaDynamicManagementKit) that stayed resident. Once I killed the
running java processes, and it restarted itself on schedule,
everything was fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top