Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:55:39+00:00 2026-06-09T00:55:39+00:00

I’m looking for a better way to set Java’s default timezone. We’re currently hitting

  • 0

I’m looking for a better way to set Java’s default timezone. We’re currently hitting our DB2 database to get it’s current timezone, but it’s not a timezone name, just the current hours/minutes offset value. So we take that value and construct an ID like “GMT-07:00”.

That seems to cause two problems:

  1. We have to make sure to reset for DST start/end. e.g. we have set up a scheduled task the queries the database and sets the timezone. Annoying.
  2. For reasons unknown to us (yet), our scheduled task will SOMETIMES set the wrong timezone.

Assuming that DB2 always returns the correct value then I can only imagine that “GMT-07:00” is vague and between Java/it’s timezone db/the OS, it plucks a different value from the table.

After computing a string like “GMT-07:00” our code does this:

 String timezoneGMTOffsetString = "GMT-07:00";
 TimeZone localTimeZone = TimeZone.getTimeZone(timezoneGMTOffsetString);
 TimeZone.setDefault(localTimeZone);
 System.setProperty("user.timezone", timezoneGMTOffsetString);

We think we’re just going to have to set the value externally and use -Duser.timezone="America/Los_Angeles" when starting Tomcat. And then we can scrap the scheduled job!

Any advice? Java 6.0_26

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:55:41+00:00Added an answer on June 9, 2026 at 12:55 am

    The preferred solution is always covert to UTC and from UTC. Use joda-time library for conversion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.