You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-issues@incubator.apache.org by "Yee-Wah Lee (JIRA)" <ad...@incubator.apache.org> on 2007/03/15 21:26:09 UTC
[jira] Created: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
-------------------------------------------------------------------------------------------------
Key: ADFFACES-410
URL: https://issues.apache.org/jira/browse/ADFFACES-410
Project: MyFaces ADF-Faces
Issue Type: Bug
Components: Components
Affects Versions: 2.0.0-incubating-core-SNAPSHOT
Reporter: Yee-Wah Lee
Priority: Minor
Fix For: 2.0.0-incubating-core-SNAPSHOT
1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
<tr:inputText value="#{date.date1}" autoSubmit="true">
<tr:convertDateTime/>
</tr:inputText>
<tr:outputText value="#{date.date1}"/>
2. When the page runs, enter a date like "1/1/07" and submit
3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
Posted by "Yee-Wah Lee (JIRA)" <ad...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/ADFFACES-410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481329 ]
Yee-Wah Lee commented on ADFFACES-410:
--------------------------------------
It seems that:
1) For formatting from Date to String, we want to use 4 digit year format for shortish style, so the code above should be executed.
2) For parsing from String -> Date, we want to use 2 digit year format. From the SimpleDateFormat javadoc about parsing the year:
For parsing with the abbreviated year pattern ("y" or "yy"), SimpleDateFormat must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the SimpleDateFormat instance is created. For example, using a pattern of "MM/dd/yy" and a SimpleDateFormat instance created on Jan 1, 1997, the string "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" would be interpreted as May 4, 1964.
During parsing, only strings consisting of exactly two digits, as defined by Character.isDigit(char), will be parsed into the default century. Any other numeric string, such as a one digit string, a three or more digit string, or a two digit string that isn't all digits (for example, "-1"), is interpreted literally. So "01/02/3" or "01/02/003" are parsed, using the same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is parsed as Jan 2, 4 BC.
=> Hence, '07' would be interpreted as 2007, and '2007' would be accepted as well.
> DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
> -------------------------------------------------------------------------------------------------
>
> Key: ADFFACES-410
> URL: https://issues.apache.org/jira/browse/ADFFACES-410
> Project: MyFaces ADF-Faces
> Issue Type: Bug
> Components: Components
> Affects Versions: 2.0.0-incubating-core-SNAPSHOT
> Reporter: Yee-Wah Lee
> Priority: Minor
> Fix For: 2.0.0-incubating-core-SNAPSHOT
>
>
> 1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
> <tr:inputText value="#{date.date1}" autoSubmit="true">
> <tr:convertDateTime/>
> </tr:inputText>
> <tr:outputText value="#{date.date1}"/>
>
> 2. When the page runs, enter a date like "1/1/07" and submit
> 3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
Posted by "Matthias Weßendorf (JIRA)" <ad...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/ADFFACES-410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Weßendorf resolved ADFFACES-410.
-----------------------------------------
Resolution: Fixed
Fix Version/s: 1.0.1-incubating-core-SNAPSHOT
thanks Yee-Wah Lee (yee-wah.lee AT oracle DOT com) for her patch
> DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
> -------------------------------------------------------------------------------------------------
>
> Key: ADFFACES-410
> URL: https://issues.apache.org/jira/browse/ADFFACES-410
> Project: MyFaces ADF-Faces
> Issue Type: Bug
> Components: Components
> Affects Versions: 1.0.1-incubating-core-SNAPSHOT
> Reporter: Yee-Wah Lee
> Assigned To: Matthias Weßendorf
> Priority: Minor
> Fix For: 1.0.1-incubating-core-SNAPSHOT
>
> Attachments: ADFFaces_410.diff
>
>
> 1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
> <tr:inputText value="#{date.date1}" autoSubmit="true">
> <tr:convertDateTime/>
> </tr:inputText>
> <tr:outputText value="#{date.date1}"/>
>
> 2. When the page runs, enter a date like "1/1/07" and submit
> 3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
Posted by "Matthias Weßendorf (JIRA)" <ad...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/ADFFACES-410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Weßendorf updated ADFFACES-410:
----------------------------------------
Fix Version/s: (was: 2.0.0-incubating-core-SNAPSHOT)
Affects Version/s: (was: 2.0.0-incubating-core-SNAPSHOT)
1.0.1-incubating-core-SNAPSHOT
> DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
> -------------------------------------------------------------------------------------------------
>
> Key: ADFFACES-410
> URL: https://issues.apache.org/jira/browse/ADFFACES-410
> Project: MyFaces ADF-Faces
> Issue Type: Bug
> Components: Components
> Affects Versions: 1.0.1-incubating-core-SNAPSHOT
> Reporter: Yee-Wah Lee
> Priority: Minor
> Attachments: ADFFaces_410.diff
>
>
> 1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
> <tr:inputText value="#{date.date1}" autoSubmit="true">
> <tr:convertDateTime/>
> </tr:inputText>
> <tr:outputText value="#{date.date1}"/>
>
> 2. When the page runs, enter a date like "1/1/07" and submit
> 3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
Posted by "Matthias Weßendorf (JIRA)" <ad...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/ADFFACES-410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Weßendorf reassigned ADFFACES-410:
-------------------------------------------
Assignee: Matthias Weßendorf
> DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
> -------------------------------------------------------------------------------------------------
>
> Key: ADFFACES-410
> URL: https://issues.apache.org/jira/browse/ADFFACES-410
> Project: MyFaces ADF-Faces
> Issue Type: Bug
> Components: Components
> Affects Versions: 1.0.1-incubating-core-SNAPSHOT
> Reporter: Yee-Wah Lee
> Assigned To: Matthias Weßendorf
> Priority: Minor
> Attachments: ADFFaces_410.diff
>
>
> 1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
> <tr:inputText value="#{date.date1}" autoSubmit="true">
> <tr:convertDateTime/>
> </tr:inputText>
> <tr:outputText value="#{date.date1}"/>
>
> 2. When the page runs, enter a date like "1/1/07" and submit
> 3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (ADFFACES-410) DateTimeConverter does not use
2DigitYearStart() when parsing strings with year less than 4-digit
Posted by "Yee-Wah Lee (JIRA)" <ad...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/ADFFACES-410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481326 ]
Yee-Wah Lee commented on ADFFACES-410:
--------------------------------------
I see the following code in the (server-side) DateTimeConverter and
think it may be problematic.
1) The default style for dates is set to shortish, which forces the year
pattern to be at least 4 digits
(http://incubator.apache.org/adffaces/trinidad-api/apidocs/org/apache/myfaces/trinidad/convert/DateTimeConverter.html)
New dateStyle shortish has been introduced. Shortish is identical to
short but forces the year to be a full four digits. If dateStyle is
not set, then dateStyle defaults to shortish.
2) Accordingly, the converter sets the pattern on its DateFormat to use
at least 4 digits, if 'y' appears at all. The method is _get4YearFormat()
3) Now, the Javadoc states this for SimpleDateFormat
(http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html)
For parsing, if the number of pattern letters is more than 2, the year
is interpreted literally, regardless of the number of digits. So using
the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
> DateTimeConverter does not use 2DigitYearStart() when parsing strings with year less than 4-digit
> -------------------------------------------------------------------------------------------------
>
> Key: ADFFACES-410
> URL: https://issues.apache.org/jira/browse/ADFFACES-410
> Project: MyFaces ADF-Faces
> Issue Type: Bug
> Components: Components
> Affects Versions: 2.0.0-incubating-core-SNAPSHOT
> Reporter: Yee-Wah Lee
> Priority: Minor
> Fix For: 2.0.0-incubating-core-SNAPSHOT
>
>
> 1. Create an inputText with an attached dateTimeConverter, and bind its value to a backing bean.
> <tr:inputText value="#{date.date1}" autoSubmit="true">
> <tr:convertDateTime/>
> </tr:inputText>
> <tr:outputText value="#{date.date1}"/>
>
> 2. When the page runs, enter a date like "1/1/07" and submit
> 3. The outputText shows that the date submitted was "1st January 7 AD", not the (more likely expected) 2007 A.D. This is despite the fact that the DateTimeConverter uses 1950 as the default century for interpreting 2 digit years.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.