Incorrect time stamps displayed by an application or in log files
 Technote (troubleshooting)
 
Problem(Abstract)
When there are problems with the time value returned to an application or written to the log files, a simple test can determine if the problem is with system configuration or the Java™ 2 SDK timezone offset values.
 
Cause
The SDK uses a combination of the SDK and the operating system default timezone to calculate the appropriate time to use when java.util.Date is invoked. In some cases, the expected result might not be correct because the hour value has not been adjusted for Daylight Saving Time.
 
Resolving the problem
Determine if the problem is related to the SDK
IBM® WebSphere® Application Server test using time.jsp. To test the SDK:
  1. Deploy the time.jsp file, (see attachment) to an existing application.
  2. To run time.jsp, put the file in the install_root/installedApps/node name/EAR directory/WAR directory for an existing application.
  3. Request time.jsp from a browser. The results display in the browser and are written to the application server stdout file.
Results of running time.jsp in the stdout file

In the stdout file, after time.jsp is run, the following information displays:

[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U Fri Apr 09 12:43:15 EDT 2004
[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U java.util.SimpleTimeZone[id=America/New_York,
offset=-18000000,
dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,
startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,
startTimeMode=0,endMode=2,endMonth=9,
endDay=-1,endDayOfWeek=1,
endTime=7200000,endTimeMode=0]
[4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U America/New_York [4/9/04 12:43:15:181 EDT] 58c81942
SystemOut U Eastern Standard Time
[4/9/04 12:43:15:181 EDT] 58c81942 SystemOut    
U Currently in daylight-savings time.

Java program test using Time Test.class
  1. Copy the TimeTest.class file, attached to this technote, to the following directory:
    install_root/java/bin
  2. At the command prompt, type:
    java TimeTest
  3. It may be necessary to recompile the TimeTest.java file.

Results of TimeTest

Fri Apr 09 12:45:11 EDT 2004
java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,
dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,
startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,
startTimeMode=0,endMode=2,endMonth=9,
endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]
America/New_York Eastern Standard Time
Currently in daylight-savings time.


Gathering System Information

Determine the timezone setting that the operating system is using. For Windows® systems, the date and time properties display the timezone. For UNIX® systems, issue the following command from a command prompt to display the timezone:

echo $TZ

Displaying the current values that the JVM™ is using

The attached JSP™ file, time.jsp, can be deployed on any application that shows symptoms of reporting the incorrect time. When time.jsp is called, it returns the following values:

  • Current date and time
  • Timezone ID
  • Long name of the timezone in use
  • Currently in/not in daylight-savings time.
  • A table of Timezone Information that is available with the SDK that is in use.


java.util.SimpleTimeZone output fields are described below:


ID

A String giving the timezone identifier (e.g., America/New_York)

offset

An integer field giving the offset in milliseconds from GMT (or UTC). The number represents the number of milliseconds that must be added to GMT time to obtain the time in this zone. For example, the US/Eastern zone has a value of -18000000. To determine the offset in hours, offset = -18000000/( 60 * 60 * 1000).

dstSavings

An integer field giving the additional offset from GMT (or UTC) in milliseconds. (The time is calculated as offset + GMT).

useDaylight

Boolean field set to indicate if the timezone switches to DST.

startYear

An integer indicating the year in which the specified daylight savings time rule took effect.

startMonth

An integer field giving the month of the year in which daylight savings time starts. 0/January, 1/February, 2/March, 3/April, 4/May, 5/June, 6/July, 7/August, 8/September, 9/October, 10/November, 11/December.

startDay

An integer giving the daylight savings ending day of the week occurrence in the month; where 1 means first occurrence, 2 means second, -1 means last occurrence, -2 means second to last occurrence, and so on.

Note that when startDayOfWeek is zero, this field represents a specific date in the month. Moreover, if startDayOfWeek is negative, this field indicates the day of the month after which the day of the week indicated by the absolute value of startDayOfWeek marks the start of daylight savings time.

startDayOfWeek

An integer field indicating the day of the week for ending daylight savings time, where 1 is Sunday and 7 is Saturday. There are some twists allowed as indicated in the startDay description above.

startTime

An integer field giving the time of day in milliseconds, starting at midnight, at which daylight savings time starts. (startTime = 7200000 / 60 * 60 * 1000).

endMonth

Same as startMonth, but for the end of daylight savings time.

endDay

Same as startDay, but for the end of daylight savings time.

endDayOfWeek

Same as startDayOfWeek, but for end of daylight savings time.

endTime

Same as startTime, but for end of daylight savings time.

Modifying the WebSphere Application Server command line arguments to use a specific timezone

If you want to specify a specific timezone that is not the same as the operating system, set the following command line argument:

-Duser.timezone=ID

An example of setting the timezone to America/Los_Angeles is:

-Duser.timezone=America/Los_Angeles

Valid timezone values display in a table when time.jsp is requested.
 
Related information
AIX Timezone Information
2007 DST Update
How to modify command line arguments
 
time.jspTimeTest.classTimeTest.java
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server
Operating system(s): Windows
Software version: 6.0
Software edition:
Reference #: 1173447
IBM Group: Software Group
Modified date: Mar 8, 2005