[ 
https://issues.apache.org/jira/browse/LANG-1219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15255367#comment-15255367
 ] 

Charles Honton commented on LANG-1219:
--------------------------------------

Upon further investigation, in the update 
DateFormatSymbols.getInstance(locale).getZoneStrings() provides more zoneNames. 
As an example:
[0]     "Europe/Paris"
[1]     "Mitteleuropäische Zeit"
[2]     "MEZ"
[3]     "Mitteleuropäische Sommerzeit"
[4]     "MESZ"
[5]     "Mitteleuropäische Zeit"
[6]     "MEZ"

I'm going to drop any duplicate entries and any keys past index 4 are in 
standard time

> FastDateFormat doesn't respect summer daylight in localized strings
> -------------------------------------------------------------------
>
>                 Key: LANG-1219
>                 URL: https://issues.apache.org/jira/browse/LANG-1219
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 3.4
>            Reporter: Jarek
>            Assignee: Charles Honton
>              Labels: timezone
>
> FastDateFormat can't properly parse dates with daylight saving in the "z" 
> pattern. It always returns date without daylight saving. Test case:
> {code:java}
>               SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy 
> HH:mm:ss z", Locale.GERMANY);
>               Date d1 = format.parse("26.10.2014 02:00:00 MESZ");
>               Date d2 = format.parse("26.10.2014 02:00:00 MEZ");
>               System.out.println(d1);
>               System.out.println(d2);
>               FastDateFormat formatt = FastDateFormat.getInstance("dd.MM.yyyy 
> HH:mm:ss z", Locale.GERMANY);
>               Date d3 = formatt.parse("26.10.2014 02:00:00 MESZ");
>               Date d4 = formatt.parse("26.10.2014 02:00:00 MEZ");
>               System.out.println(d3);
>               System.out.println(d4); 
> {code}
> returns:
> SDF: Sun Oct 26 02:00:00 CEST 2014
> SDF: Sun Oct 26 02:00:00 CET 2014
> FDF: Sun Oct 26 02:00:00 CET 2014
> FDF:  Sun Oct 26 02:00:00 CET 2014
> FastDateFormat returns the same date, which is wrong.
> Bug is in the FastDateParser.TimeZoneStrategy.setCalendar:
> {code:java}
> @Override
>         void setCalendar(final FastDateParser parser, final Calendar cal, 
> final String value) {
>             TimeZone tz;
>             if(value.charAt(0)=='+' || value.charAt(0)=='-') {
>                 tz= TimeZone.getTimeZone("GMT"+value);
>             }
>             else if(value.startsWith("GMT")) {
>                 tz= TimeZone.getTimeZone(value);
>             }
>             else {
>                 tz= tzNames.get(value);
>                 if(tz==null) {
>                     throw new IllegalArgumentException(value + " is not a 
> supported timezone name");
>                 }
>             }
>             cal.setTimeZone(tz);
>         }
> {code}
> It's not enough to just call: cal.setTimeZone.
> If zone names in standard and daylight time are different, you have to check 
> the name in DateFormatSymbols.getInstance(locale).getZoneStrings(); and if 
> it's >= 3, you have to activate daylight mode.Just like SimpleDateFormat does 
> it:
> {code:java}
> 1491            // (abbreviation) for both standard and daylight time,
> 1492            // let the time zone in the Calendar decide which one.
> 1493            if (!useSameName) {
> 1494                calendar.set(Calendar.ZONE_OFFSET, tz.getRawOffset());
> 1495                calendar.set(Calendar.DST_OFFSET,
> 1496                             j >= 3 ? tz.getDSTSavings() : 0);
> 1497            }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to