Ticket #5964 (closed defect: fixed)

SVN Diffs for #5964

 

Opened 1 year ago

Last modified 1 year ago

TimeZone.getTimeZone(timezone) fails for GMT+8:30 (although spec'ed)

Reported by: mark Assigned to: mark
Priority: major Milestone: 3.8.1
Component: formatting Version:
Keywords: Cc:
Load: Xref: 5945,5990
Java Version: Operating System:
Project (C/J): all Weeks: 0.2
Review: emmons

Description

There are three problems. 1. Although it is spec'ed to handle GMT+8:30, what it returns is a simple timezone with the ID "GMT" instead of "GMT+8:30". So any subsequent creation from that zone id will fail. 2. Some zones (since 1970) have non-zero seconds, so it should also handle GMT+8:30:21. 3. When it fails, it should return a zone with ID "Etc/Unknown"

Attachments

Change History

09/27/07 08:40:26 changed by mark

  • status changed from new to assigned.

#1

id = "GMT+8:30";
zone = TimeZone.getTimeZone(id);
newID = zone.getID();
// Fails: id != newID

09/27/07 08:54:50 changed by yoshito

  • xref set to 5945.

09/27/07 08:56:24 changed by mark

Should accept:
GMT+8
GMT+08
GMT+830
GMT+0830
GMT+8:30
need following for full compat:
GMT+83030
GMT+083030
GMT+08:30:30

And the "Etc/GMT" formats of those.

In the JDK it has:
The syntax of a custom time zone ID is:

     CustomID:
             GMT Sign Hours : Minutes
             GMT Sign Hours Minutes
             GMT Sign Hours
     Sign: one of
             + -
     Hours:
             Digit
             Digit Digit
     Minutes:
             Digit Digit
     Digit: one of
             0 1 2 3 4 5 6 7 8 9
     

In ICU4J
If the time zone you want is not represented by one of the supported IDs, then you can create a custom time zone ID with the following syntax:

     GMT[+|-]hh[[:]mm]
     

http://bugs.icu-project.org/trac/ticket/5945

09/27/07 09:10:23 changed by mark

Should accept:

    * GMT+8
    * GMT+08
    * Etc/GMT-8
    * GMT+830
    * GMT+0830
    * GMT+8:30
    * Etc/GMT-830
    * need following for full compat:
    * GMT+83030
    * GMT+083030
    * GMT+08:30:30
    * Etc/GMT-83030


We normalize within getID() for GMT format: 
GMT+... all use leading zero, colons, and 
for the Etc/GMT format to no leading zero, no colon

For comparison
   java.util.TimeZone zone2 = java.util.TimeZone.getTimeZone("GMT+830");
   System.out.println(zone2.getID());
   zone2 = java.util.TimeZone.getTimeZone("GMT+08");
   System.out.println(zone2.getID());
   zone2 = java.util.TimeZone.getTimeZone("Etc/GMT-8");
   System.out.println(zone2.getID());
GMT+08:30
GMT+08:00
Etc/GMT-8

11/28/07 13:17:00 changed by yoshito

  • xref changed from 5945 to 5945,5990.

11/28/07 13:31:24 changed by yoshito

  • revw set to emmons.
  • milestone changed from 4.0 to 3.8.1.

The fix was made as a part of #5990.

01/04/08 12:07:52 changed by emmons

  • status changed from assigned to closed.
  • resolution set to fixed.

Add/Change #5964 (TimeZone.getTimeZone(timezone) fails for GMT+8:30 (although spec'ed))




Anti spam check: