Time zone configuration

When you have Java™ programs that are sensitive to time zones, you should configure the time zone on your server so that your Java programs use the correct time.

To determine the local time correctly, the Java virtual machine (JVM) requires that you set both the QUTCOFFSET i5/OS™ system value and the time of day information in the LOCALE user parameter for the current user or job:

Note: An alternative to setting QUTCOFFSET and LOCALE is to use the QTIMZON system value. The JVM looks to the system QLOCALE object first. If not found, the JVM will then look at the QTIMZON system value. If the QTIMZON system value contains a non-recognized QTIMZON object, the JVM defaults user.timezone to UTC.

QUTCOFFSET and user.timezone

The QUTCOFFSET i5/OS system value represents the Coordinated Universal Time (UTC) Offset for your system. QUTCOFFSET specifies the difference in time between UTC (or Greenwich mean time) and the current system time. The default value for QUTCOFFSET is zero (+00:00).

The QUTCOFFSET value allows the JVM to determine the correct value for the local time. For example, the value for QUTCOFFSET to specify central standard time (CST) is -6:00. To specify central daylight time (CDT), QUTCOFFSET has a value of -5:00.

The user.timezone Java system property uses UTC time as the default value. Unless you specify a different value, the JVM recognizes UTC time as the current time.

For more information about QUTCOFFSET and Java system properties, see the following topics:

i5/OS system value: QUTCOFFSET

Java system properties

LOCALE

The LOCALE parameter on a user profile specifies the *LOCALE object to use for the LANG environment variable. Do not confuse the *LOCALE object with Java locales.

Correctly setting the locale information allows the JVM to set the user.timezone property to the correct time zone. You can set the user.timezone property to override the default setting provided by the *LOCALE object.

For more information about using locales and setting Java system properties, see the following pages:

Locales

Java system properties

The LC_TOD category defines rules for daylight savings time and time zone information for a locale.

Note: To use daylight savings time, you must adjust the QUTCOFFSET system value to have the correct offset.

The following example shows the LC_TOD category information that you must include in the locale object in order to configure the correct time zone for Java:

     LC_TOD

     % TZDIFF is number of minutes difference from UTC (or GMT)
     tzdiff   360
     % Timezone name (this is the value that you would have
     % passed to the JVM as the user.timezone property.)
     tname    "<C><S><T>"
     % Remember to adjust the value of QUTCOFFSET when using
     % daylight savings time (DST)
     % Name used for DST.
     dstname   "<C><D><T>"
     % DST start in this part of the US is the first Sunday in 
     % April at 2am
     dststart 4,1,1,7200
     % DST End in this area of US is Last Sunday in October.
     dstend   10,-1,1,7200
     % shift in seconds
     dstshift 3600

     END LC_TOD

The LC_TOD category of the locale contains the tname field, which you must set to the same value as your time zone. For valid time zone strings, refer to the Javadoc reference information for the java.util.TimeZone class. For more information about working with locales, see the following pages:

Work with locales

TimeZone Javadoc reference information

Related concepts
Java character encodings
Related reference
Examples: Creating an internationalized Java program