IBM Support

MustGather: 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 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.

Collecting data



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 .

    Setup
      Download the following files to the same directory
      · os_timezone.[bat|sh]
      · TimeTest.class

      If you want to compile your own version of the TimeTest.class, download the .java file.

    Execution
      Before you start, look at a wall clock and document the time (and your timezone) when you started the test.

      os_timezone.[bat|sh] [JAVA_HOME]

      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
      date
      echo $TZ
      (Linux only)  ls -al /etc/localtime
      (Linux only)  ls -al /etc/timezone
      (Linux only)  grep ZONE /etc/sysconfig/clock
      [JAVA_HOME]/jre/bin/java -version
      [JAVA_HOME]/jre/bin/java -cp . TimeTest

      Windows
      date /T
      time /T
      tzutil /g
      w32tm /TZ
      [JAVA_HOME]\jre\bin\java -version
      [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
  1. Insert 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. One of the sample applications that comes with WebSphere Application Server, such as DefaultApplication.
  3. 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

B. Deploy the EAR file
  1. Download and deploy the TimeMustgather.ear at the bottom of this document.
  2. Start the application
  3. In a browser, go to http://localhost:9080/TimeMustgather/time.jsp to launch the JSP.
The results display in the browser (which lists all valid timezones that the SDK knows about) and additional details about the current timezone are written to the application server log file, SystemOut.log.
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,
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.



Manual Steps

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

date /T
time /T
tzutil /g
w32tm /TZ

For UNIX® systems, issue the following commands from a command prompt to display the timezone:

date
echo $TZ


For Linux® systems, run the following commands.

date
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:
    <JAVA_PATH>/jre/bin/java -version

    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
    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.

Meaning of the parameters are documented in the javadoc API:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/SimpleTimeZone.html

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
    • SystemOut.log
    • SystemErr.log
    • native_stdout.log
    • native_stderr.log
  • 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.
NOTE: Support may ask that TimeTest.class be run with a forced timezone to compare output (by using "-Duser.timezone=" argument)




Additional Information


    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.
    WORKAROUNDS
      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:

        -Duser.timezone= ID

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

        -Duser.timezone=America/Los_Angeles

        NOTE: Valid timezone values display in a table when time.jsp is requested.
      Applying the timezone updates via the JTZU tool Upgrading the SDK
        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.


    Related information

    AIX Timezone Information

    Cross reference information
    Segment Product Component Platform Version Edition
    Application Servers Runtimes for Java Technology Java SDK

    Document information

    More support for: WebSphere Application Server

    Software version: 7.0, 8.0, 8.5, 8.5.5, 9.0.0.0

    Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

    Software edition: Edition Independent

    Reference #: 1173447

    Modified date: 16 December 2016


    Translate this page: