commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles Honton (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1192) FastDateFormat does not support the week-year component (uppercase 'Y')
Date Sat, 12 Dec 2015 17:50:46 GMT

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

Charles Honton commented on LANG-1192:
--------------------------------------

To make 'Y' useful, the internal Calendar must be exposed to allow the minimalDaysInFirstWeek
and firstDayOfWeek to be set.  Unfortunately, this has side-effect of limiting thread safety.
 To obtain ISO8601 behavior, we could set internal calendar instances to have minimalDaysInFirstWeek=4
and firstDayOfWeek=MONDAY.  Or, we could provide a way for client to provide Calendar instance
(also useful for  LANG-933)

> FastDateFormat does not support the week-year component (uppercase 'Y')
> -----------------------------------------------------------------------
>
>                 Key: LANG-1192
>                 URL: https://issues.apache.org/jira/browse/LANG-1192
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>    Affects Versions: 3.4
>            Reporter: Dominik Stadler
>            Assignee: Charles Honton
>
> The Java SimpleDateFormat supports two year-components, 'y' for normal year and 'Y' for
'Week year', see http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
> However when we try to use FastDateFormat to parse a format which uses the week-year,
it fails with an exception
> {noformat}
> java.lang.IllegalArgumentException: Illegal pattern component: YYYY
> 	at org.apache.commons.lang3.time.FastDatePrinter.parsePattern(FastDatePrinter.java:282)
> 	at org.apache.commons.lang3.time.FastDatePrinter.init(FastDatePrinter.java:149)
> 	at org.apache.commons.lang3.time.FastDatePrinter.<init>(FastDatePrinter.java:142)
> 	at org.apache.commons.lang3.time.FastDateFormat.<init>(FastDateFormat.java:384)
> 	at org.apache.commons.lang3.time.FastDateFormat.<init>(FastDateFormat.java:369)
> 	at org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:91)
> 	at org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:88)
> 	at org.apache.commons.lang3.time.FormatCache.getInstance(FormatCache.java:82)
> 	at org.apache.commons.lang3.time.FastDateFormat.getInstance(FastDateFormat.java:119)
> {noformat}
> Simple unit test to reproduce this:
> {code}
>     @Test
>     public void testCommonsLang() {
>     	Date date = new Date();
>     	Format dateFormat = new SimpleDateFormat("YYYY");
> 		assertNotNull(dateFormat.format(date));
>         dateFormat = FastDateFormat.getInstance("YYYY");
> 		assertNotNull(dateFormat.format(date));
>     }
> {code}



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

Mime
View raw message