MustGather: Incorrect time stamps displayed by an application or in log files
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 SDK timezone offset values
Resolving the problem
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 SDK timezone offset values.
Running the Automated Script (os_timezone.[bat|sh])
To collect both the Java information and the system information, you can use the provided
os_timezone.[bat|sh] script provided at the bottom of this document.
NOTE: This script will not execute the time.jsp, which has to be first inserted into an EAR file and then accessed separately either in a web browser, or (on UNIX or Linux) by using the commands wget or curl .
Download the following files to the same directory
If you want to compile your own version of the TimeTest.class, download the .java file.
Before you start, look at a wall clock and document the time (and your timezone) when you started the test.
JAVA_HOME is the path to the root of the java directories (usually the folder named "java"). For example, /usr/IBM/WebSphere/AppServer/java/ is a valid path.
Because the script outputs both stdout and stderr, when you redirect output to a file, you will need to add an extra argument to the end of the line:
os_timezone.[bat|sh] [JAVA_HOME] > output.txt 2>&1
NOTE: For UNIX/Linux, make sure that you set the permissions on the script file so it's executable.
What the script executes...
For your reference, here is a summary of the commands run by the script:
AIX, HP-UX, Linux, Solaris
(Linux only) ls -al /etc/localtime
(Linux only) ls -al /etc/timezone
(Linux only) grep ZONE /etc/sysconfig/clock
[JAVA_HOME]/jre/bin/java -cp . TimeTest
[JAVA_HOME]\jre\bin\java -cp . TimeTest
Running the JSP file (time.jsp)
IBM WebSphere Application Server test using time.jsp. To test the application server, you have two options:
A. Insert time.jsp into existing application
- Insert the time.jsp file, (see attachment) to an existing application.
- To run time.jsp, put the file in the install_root/installedApps/node name/EAR directory/WAR directory for an existing application. One of the sample applications that comes with WebSphere Application Server, such as DefaultApplication.
- Request time.jsp from a browser. By default (for the DefaultApplication) it will be http://localhost:9080/time.jsp, but you may need to add a context-root to the URL (check the web.xml for what the context-root is for the EAR/WAR). NOTE: Replace localhost:9080 with the desired host and port
- Download and deploy the TimeMustgather.ear at the bottom of this document.
- Start the application
- In a browser, go to http://localhost:9080/TimeMustgather/time.jsp to launch the JSP.
Save the webpage and send in the HTML file as part of the data collection.
Screenshot of the webpage:
Log output after launching time.jsp
In the SystemOut.log file, after time.jsp is launched, the following information displays, which is similar to the output of TimeTest.class:
[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,
[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.
Gathering System Information (command-line)
Look at a wall clock and document the time you started the data capture (note the timezone you are in).
The commands below will help determine the timezone setting that the operating system is using:
For Windows® system:
Take a screenshot of the Date and Time dialog, located at Control Panel > Date and Time
Also run these commands from the command line
For UNIX® systems, issue the following commands from a command prompt to display the timezone:
For Linux® systems, run the following commands.
ls -al /etc/localtime
ls -al /etc/timezone
grep ZONE /etc/sysconfig/clock
The files localtime and timezone are usually symbolic links to the appropriate timezone file, but this is not always the case, as different flavors of Linux handle timezones differently. If you have access to the GUI, you can also open up the date and time settings and take a screenshot.
Java standalone test (TimeTest.class)
1. Copy the TimeTest.class file (see the bottom of this document) to a temporary directory.
2. From the command prompt, navigate to this temporary directory.
3. Locate your java executable and note the path, for example /usr/IBM/WebSphere/AppServer/java/
4. Execute the command, supplying the full path to the java executable:
<JAVA_PATH>/jre/bin/java -cp . TimeTest
5. Obtain the current Java version, also supplying the full path to the java executable:
NOTE: If you place TimeTest.class in the directory where the java executable resides, you won't need to supply the classpath argument, "-cp ."
The TimeTest.java source code is provided if you would like to recompile it, which may be necessary in some cases.
Output of TimeTest.class
This will be output to the standard out (usually the command prompt) when TimeTest.class is run.
Fri Apr 09 12:45:11 EDT 2004
America/New_York Eastern Standard Time
Currently in daylight-savings time.
Meaning of the parameters are documented in the javadoc API:
Some of the parameters have special rules, so refer to the API for further information. Also note that some values can be negative.
Further details about the values are found in the Additional Information section.
Data to Upload to Support
- Time on wall clock when capturing data (note your timezone)
- WebSphere Application Server logs
- Java version information (./java -version)
- You can also capture a javacore from the running JVM.
- Java command line arguments (can be obtained from the javacore, server.xml, or from the process list)
- HTML output of time.jsp
- Output from running os_timezone script
- If ran TimeTest.class standalone, supply the command line you ran along with the output.
- 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.
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:
A String giving the timezone identifier (e.g., America/New_York)
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).
An integer field giving the additional offset from GMT (or UTC) in milliseconds. (The time is calculated as offset + GMT).
Boolean field set to indicate if the timezone switches to DST.
An integer indicating the year in which the specified daylight savings time rule took effect.
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.
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.
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.
An integer field giving the time of day in milliseconds, starting at midnight, at which daylight savings time starts. (startTime = 7200000 / 60 * 60 * 1000).
Same as startMonth, but for the end of daylight savings time.
Same as startDay, but for the end of daylight savings time.
Same as startDayOfWeek, but for end of daylight savings time.
Same as startTime, but for end of daylight savings time.
Modifying the JVM's 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 generic JVM argument:
An example of setting the timezone to America/Los_Angeles is:
NOTE: Valid timezone values display in a table when time.jsp is requested.
You can update only the timezone database in each SDK installed using the JTZU tool. For more information on this tool, navigate to the following pages:
Changes to Daylight Saving Time
Olson time zone updates for Java JRE and SDK service refreshes for IBM products
IBM Time Zone Update Utility for Java - Version X.X.XXX
Upgrading to the latest SDK will include the updated timezone database (
as per these charts) along with the SDK. Please consult your product's support pages for upgrade details and fix pack downloads.
|Application Servers||Runtimes for Java Technology||Java SDK|
More support for:
WebSphere Application Server
Software version: 7.0, 8.0, 8.5, 8.5.5, 220.127.116.11
Operating system(s): AIX, HP-UX, Linux, Solaris, Windows
Software edition: Edition Independent
Reference #: 1173447
Modified date: 16 December 2016
Translate this page: