You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/01/08 17:34:07 UTC
svn commit: r610057 - in /myfaces/tomahawk/trunk/core/src:
main/java/org/apache/myfaces/dateformat/
main/resources/org/apache/myfaces/custom/calendar/resource/
test/java/org/apache/myfaces/dateformat/
Author: skitching
Date: Tue Jan 8 08:34:06 2008
New Revision: 610057
URL: http://svn.apache.org/viewvc?rev=610057&view=rev
Log:
Fix bug with handling of 2-digit years.
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/dateformat/TestSimpleDateFormatter.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java?rev=610057&r1=610056&r2=610057&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java Tue Jan 8 08:34:06 2008
@@ -80,6 +80,8 @@
public DateFormatSymbols(Locale l)
{
+ this();
+
java.text.DateFormatSymbols src = new java.text.DateFormatSymbols(l);
this.eras = src.getEras();
this.months = src.getMonths();
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java?rev=610057&r1=610056&r2=610057&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/SimpleDateFormatter.java Tue Jan 8 08:34:06 2008
@@ -789,6 +789,8 @@
if (context.ambiguousYear)
{
// TODO: maybe this adjustment could be made while parsing?
+
+ context.year += 1900;
Date date = createDateFromContext(context);
Date threshold = symbols.twoDigitYearStart;
if (date.getTime() < threshold.getTime())
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js?rev=610057&r1=610056&r2=610057&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/date.js Tue Jan 8 08:34:06 2008
@@ -599,6 +599,7 @@
{
if (context.ambiguousYear)
{
+ context.year += 1900;
var date = this._createDateFromContext(context);
var threshold = symbols.twoDigitYearStart;
if (date.getTime() < threshold.getTime())
Modified: myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/dateformat/TestSimpleDateFormatter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/dateformat/TestSimpleDateFormatter.java?rev=610057&r1=610056&r2=610057&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/dateformat/TestSimpleDateFormatter.java (original)
+++ myfaces/tomahawk/trunk/core/src/test/java/org/apache/myfaces/dateformat/TestSimpleDateFormatter.java Tue Jan 8 08:34:06 2008
@@ -189,6 +189,15 @@
// test mismatched quoted text
"yyyy'year'MM'month'dd", "2003yexr04month06", null,
+
+ // test short year format with no century wraparound
+ "yy-MM-dd", "99-04-06", new Date(1999-1900, 03, 06),
+
+ // test short year format with century wraparound
+ "yy-MM-dd", "03-04-06", new Date(2003-1900, 03, 06),
+
+ // test short year format with no century wraparound
+ "yy-MM-dd", "33-04-06", new Date(1933-1900, 03, 06),
};
Locale locale = Locale.ENGLISH;