Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4050886

Date.toString() returns GMT timezones for TZ outside US (change from JDK1.0.2)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.1.1
    • core-libs
    • None
    • sparc
    • solaris_9

    Description

      java.util.Date.toString() returns GMT style timezones when
      outside US timezones in JDK1.1 This is different from JDK1.0.2

      For example when in BST (British Standard Time? in UK),
      Date.toString() in JDK1.1.1 returns something like:

      Sat May 10 03:58:56 GMT+06:00 1997

      In JDK1.0.2 this same method returns a date string like:

           Fri May 09 21:59:36 BST 1997

      Note the "BST" vs. "GMT+06:00". I got these strings by
      running the small test program below. To switch to the
      BST timezone set the env var TZ=BST.

      import java.util.Date;
       
      public class date {
          public static void main(String argv[]) {
              Date d = new Date();
              System.out.println("java date: " + d.toString());
          }
      }

      Looking at the implementation of Date.toString in JDK1.1.1
      shows that it explicitly uses the US locale. The problem may
      be that the DateFormatTimeZone_en.java resource bundle should
      include other non-us timezone names. Or it may be that using
      the US locale is incorrect. Or this may be intended. It certainly
      causes confusion to the submitter of this bug.

      --- Original description below ---

      I have been running the applet (which I attach to this bug report) for some
      time now on my home page (http://kelvin.uk/~petert). Under Netscape from
      /usr/dist and earlier versions of hotjava it has worked fine. However, currently
      the date printed out reads as follows:-

      Fri May 09 13:51:59 GMT+01:00 1997

      This is obviously wrong, under Netscape I get:-

      Fri May 09 13:51:59 BST 1997

      Which is correct.

      Attachments

        Issue Links

          Activity

            People

              ssenthilsunw Shanmugam Senthil (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: