Ticket #6644 (closed defect: fixed)

Bug contains 2 commit(s) | SVN Diffs for #6644

 

Opened 1 year ago

Last modified 3 months ago

getDisplayName problem in ICU4J

Reported by: yoshito Assigned to: yoshito
Priority: major Milestone: 4.1.2
Component: formatting Version: 4.0
Keywords: Cc:
Load: Xref: 6597
Java Version: Operating System:
Project (C/J): ICU4J Weeks: 0.1
Review: srl

Description

The ICU4C problem reported by ticket#6597 is also reproduced with ICU4J. ICU4J does not have the equivalent failing test case. With the equivalent test case, ICU4J implementation still did not fail, because of the internal formatter cache. However, when changing the order of test case data, the exact same issue is reproduced.

Attachments

Change History

12/01/08 08:25:23 changed by yoshito

  • milestone changed from UNSCH to 4.1.2.

A message from Kenchan in icu-support ML :

Hi,
 
The ICU4J 4.0 API getDisplayName() for a timezone does not display the correct
daylight long name, when the requested TimeZone is not in DST at present.
Instead, the resulting output we get is the display name of the timezone of
the machine. This was working fine before 2nd Nov,2008 for “America/Los_Angeles”
as DST was on before. 
Please find below the code snippets and the corresponding results.
 
ULocale locale = new ULocale(“en”);
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
String displayName0 = tz.getDisplayName(true, 1, locale); // Daylight Long
System.out.println("Daylight long: "+ displayName0);
 
OUTPUT: 
Daylight long: India Standard Time    
EXPECTED :
Daylight long: Pacific Daylight Time  
 
However, if the standard time zone name is requested before the daylight name, the result is correct.
 
ULocale locale = new ULocale(“en”);
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
String displayName0 = tz.getDisplayName(false, 1, locale); // Standard Long
String displayName0 = tz.getDisplayName(true, 1, locale); // Daylight Long
System.out.println("Daylight long: "+ displayName0);
 
OUTPUT:
Daylight long: Pacific Daylight Time
EXPECTED:
Daylight long: Pacific Daylight Time
 
I am able to achieve the correct results by making the following change in TimeZone.java :
When the timezone is not currently in DST, July1 date is created. After this
we need to set the timezone to the requested Timezone.
I have highlighted the else block, which I added to the implementation of getdisplayname().
 
if (daylight && useDaylightTime()) {
                // The display name for daylight saving time was requested, but currently not in DST
 
                // Set a fixed date (July 1) in this Gregorian year
                GregorianCalendar cal = new GregorianCalendar(this);
                cal.set(Calendar.MONTH, Calendar.JULY);
                cal.set(Calendar.DATE, 1);
 
                // Get July 1 date
                d = cal.getTime();
 
                // Check if it is in DST
                if (cal.get(Calendar.DST_OFFSET) == 0) {
                    // We need to create a fake time zone
                    tz = new SimpleTimeZone(offsets[0], getID(),
                            Calendar.JUNE, 1, 0, 0,
                            Calendar.AUGUST, 1, 0, 0,
                            getDSTSavings());
                    format.setTimeZone(tz);
                }
                
                else {
                            format.setTimeZone(this);
                           }
            }
 
Please let me know if this is a known issue and if the above resolution is fine.
 
Thanks,
Kanchan

12/01/08 10:22:16 changed by yoshito

  • revw set to srl.

05/11/09 15:59:06 changed by srl

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

12/02/09 01:56:31 changed by anonymous

12/02/09 23:32:04 changed by kareem198625@...

now,<a href="http://www.newpaulsmith.com/paul-smith-shoes-c-518.html"> Paul Smith shoes</a>,<a href="http://www.newpaulsmith.com/paul-smith-sweaters-c-526.html"> paul smith clothing</a>, and<a href="http://www.newpaulsmith.com/paul-smith-sweaters-c-526.html"> paul smith swimwear</a> are beautifully crafted with brilliant attention to detail. Paul Smith socs are an unexpected element of fun to any ensemble. Collections are primarily produced in England and Italy, while the fabrics used are mainly of Italian, French and British origin.


Add/Change #6644 (getDisplayName problem in ICU4J)




Anti spam check: