You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org> on 2009/06/17 19:06:07 UTC

[jira] Created: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
--------------------------------------------------------------------------------------------------

                 Key: TRINIDAD-1512
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
             Project: MyFaces Trinidad
          Issue Type: Bug
          Components: Components
    Affects Versions:  1.2.11-core
            Reporter: Yee-Wah Lee
            Priority: Minor


1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
        <af:outputText value="#{demoInput.date}">
        <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
        </af:outputText>

where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM

2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
    6/17/2009 1:00:00 PM GMT-05:00

If using the JSF standard DateTimeConverter, the output is:
   Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720783#action_12720783 ] 

Yee-Wah Lee commented on TRINIDAD-1512:
---------------------------------------

The zone.setID(..) code seems to be done because of performance reasons.  If the date time converter supported full strings in the timezone display, it would have to send down the translations for the possible timezone names, e.g. "EDT", "PST" and "Eastern Daylight Time", "Pacific Standard Time". 

Even if taking the commonly used timezones (300+ out of possible 500+), that would add substantial size since the locale file data would serve all converters on the page, and some could have timeStyle="full", some would have timeStyle="long" hence it would need to contain all formatting variants of the timezone name.  



> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12729445#action_12729445 ] 

Yee-Wah Lee commented on TRINIDAD-1512:
---------------------------------------

Problem seen starting from JDK 1.6.0, not in any of the 1.5 (I tested up to 1.5.0_18).

> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yee-Wah Lee updated TRINIDAD-1512:
----------------------------------

    Status: Patch Available  (was: Open)

> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>         Attachments: branch12114_1512.diff, trin12_1512.diff
>
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733903#action_12733903 ] 

Yee-Wah Lee commented on TRINIDAD-1512:
---------------------------------------

Although this used to work in JDK 1.5, I'm not convinced this is a JDK issue. Since we are creating a custom timezone in getFormattingTimeZone(), and the JDK documentation states: "No daylight saving time transition schedule can be specified with a custom time zone ID."
http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html#setID%28java.lang.String 

We used to clone the TimeZone so it would have the DST transition rules, and the JDK 6 code now enforces that those rules aren't even looked at when creating the timezone's display name. 

Instead of using the DST transition rules, the DateTimeConverter can get the formattingTimeZone() with the value to be formatted included, so it instead does:     
  StringBuilder zoneId = new StringBuilder(9);
  int offset = zone.getOffset((Date) value); 

> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720772#action_12720772 ] 

Yee-Wah Lee commented on TRINIDAD-1512:
---------------------------------------

This is related to the code in trinidadinternal.convert.DateTimeConverter#getFormattingTimeZone().  In that method, it copies the converter's timezone and gives the clone a  custom ID:
    // set the id as "GMT Sign Hours : Minutes"
    StringBuilder zoneId = new StringBuilder(9);
    int rawOffset = zone.getRawOffset();
..
    int minutes = (rawOffset % _MILLIS_PER_HOUR) / _MILLIS_PER_MINUTE;
    if (minutes < 10)
    {
      zoneId.append('0');
    }
    zoneId.append(minutes);
    zone.setID(zoneId.toString());

This sets the ID as "GMT+rawOffset" (raw offset is independent of dst) for the timezone "America/New_York", which is -5h. 

Subsequently, when formatting the string, the underlying DateFormat calls TimeZone.getDisplayName() which checks if a custom ID is specified and returns that string.
	String id = getID();
	String[] names = getDisplayNames(id, locale);
	if (names == null) {
	    if (id.startsWith("GMT")) {
		char sign = id.charAt(3);
		if (sign == '+' || sign == '-') {
		    return id;
		}
	    }


> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Gabrielle Crawford (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gabrielle Crawford updated TRINIDAD-1512:
-----------------------------------------

       Resolution: Fixed
    Fix Version/s:  1.2.12-core
           Status: Resolved  (was: Patch Available)

> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>             Fix For:  1.2.12-core
>
>         Attachments: branch12114_1512.diff, trin12_1512.diff
>
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1512) ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings

Posted by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733899#action_12733899 ] 

Yee-Wah Lee commented on TRINIDAD-1512:
---------------------------------------

Sent an email out to dev mailing list, discussing if this is a JDK issue. Excerpting the relevant code here:
1)  DateTimeConverter.java#getFormattingTimeZone(TimeZone tZone)
This effectively creates a timezone with customized id.   TimeZone zone = (TimeZone) tZone.clone();
  // set the id as "GMT Sign Hours : Minutes"
  StringBuilder zoneId = new StringBuilder(9);
  int rawOffset = zone.getRawOffset();
   ..  code to calculate and append GMT ± hours:mins
  zone.setID(zoneId.toString());
  return zone;


2) JDK 1.5: SimpleDateFormat#subFormat()
The 1.5 format code would look up a zone info file using the date's offset and daylight savings.
      case 17: // 'z' - ZONE_OFFSET
          int zoneIndex =   formatData.getZoneIndex(calendar.getTimeZone().getID());
          if (zoneIndex == -1) {
              value = calendar.get(Calendar.ZONE_OFFSET) +  calendar.get(Calendar.DST_OFFSET);
             buffer.append(ZoneInfoFile.toCustomID(value));           <---------Uses this code path
         }....

3) JDK 6: SimpleDateFormat#subFormat()
The 1.6 code now checks the DateFormatSymbols.locale and isZoneStringsSet(). By default, the locale would be null and zoneStringsSet = false unless user overrides either.It then calls TimeZone.getDisplayName() instead of checking the zoneInfoFile.

      case 17: // 'z' - ZONE_OFFSET
         if (formatData.locale == null || formatData.isZoneStringsSet) {
             ..
             // same as 1.5, looks up zone info file
          String[][] zoneStrings = formatData.getZoneStringsWrapper();
          buffer.append(zoneStrings[zoneIndex][index]);
       } else {
          TimeZone tz = calendar.getTimeZone();
          boolean daylight = (calendar.get(Calendar.DST_OFFSET) != 0);
          int tzstyle = (count < 4 ? TimeZone.SHORT : TimeZone.LONG);
          buffer.append(tz.getDisplayName(daylight, tzstyle, formatData.locale));         <------------ Uses this code path
      }...

4) JDK 1.5/6: TimeZone.getDisplayName()
This method is the same in both JDKs, but only called in JDK 6 case. If the ID is customized (GMT ±x), it simply returns that.

  String id = getID();
  String[] names = getDisplayNames(id, locale);
  if (names == null) {
      if (id.startsWith("GMT")) {
        char sign = id.charAt(3);
        if (sign == '+' || sign == '-') {
            return id; 
Therefore, the display name for the Converter's timezone in JDK 6 is fixed as its ID (GMT+/-rawOffset). 


> ConvertDateTime uses static GMT+x string for timezone display, doesn't update for daylight savings
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1512
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1512
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions:  1.2.11-core
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Create a jsp that uses tr:convertDateTime to display timezone, e.g. 
>         <af:outputText value="#{demoInput.date}">
>         <af:convertDateTime type="both" timeStyle="full" timeZone="America/New_York"/>
>         </af:outputText>
> where demoInput.date returns the current date, e.g. June 17 09, 1:00 PM
> 2. Run the jsp. For June 17 09 the timezone is actually EDT (GMT - 4). Instead it displays as EST
>     6/17/2009 1:00:00 PM GMT-05:00
> If using the JSF standard DateTimeConverter, the output is:
>    Jun 17, 2009 1:00:00 PM EDT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.