[richfaces-issues] [JBoss JIRA] Resolved: (RF-8163) rich:calendar switching between JulianCalendar and Gregorian

Nick Belaevski (JIRA) jira-events at lists.jboss.org
Tue Mar 16 18:56:38 EDT 2010


     [ https://jira.jboss.org/jira/browse/RF-8163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nick Belaevski resolved RF-8163.
--------------------------------

    Fix Version/s:     (was: 3.3.3.Final)
       Resolution: Rejected


Not a bug. Here is excerpt from the JavaDoc for SimpleDateFormat: "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."

This program:

	public static void main(String[] args) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy");
		sdf.setLenient(false);

		Date date;

		date = sdf.parse("26.2.5");
		System.out.println(date);
		date = sdf.parse("26.2.05");
		System.out.println(date);
	}

outputs the following:

Thu Feb 26 00:00:00 EET 5
Sat Feb 26 00:00:00 EET 2005

5 AD is definitely a date from Julian calendar. 

To work around the problem, provide converter that will handle this input appropriately.

> rich:calendar switching between JulianCalendar and Gregorian
> ------------------------------------------------------------
>
>                 Key: RF-8163
>                 URL: https://jira.jboss.org/jira/browse/RF-8163
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-input
>    Affects Versions: 3.3.2.CR1, 3.3.2.GA
>         Environment: Windows (several versions), Tomcat 6.0.18, MS IE 8 or Firefox 3.0.
>            Reporter: Thomas Morper
>            Assignee: Nick Belaevski
>         Attachments: screenshot-1.jpg, screenshot-2.jpg
>
>
> We have several rich:calendar elements at our application with date format dd-mm-yy hh:mm. We now hve the following problem: When a user types in a date without using the calendar-popup and uses a single-number year without a leading zero (e. g. 12.12.1 12:12), the calendar accepts the input (correct), but it creates a JulianCalendar for the Date cariable at the according bean, while it creates a GregorianCalendar for 12.12.01 12:12 or any other input with two digits for the year.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list