You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2011/01/21 01:09:15 UTC

svn commit: r1061584 - /myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java

Author: gcrawford
Date: Fri Jan 21 00:09:14 2011
New Revision: 1061584

URL: http://svn.apache.org/viewvc?rev=1061584&view=rev
Log:
TRINIDAD-1931 Date-Time converter does not use 2DigitYearStart for parsing

Thanks to yee wah for patch

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java?rev=1061584&r1=1061583&r2=1061584&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/DateTimeConverter.java Fri Jan 21 00:09:14 2011
@@ -1736,43 +1736,52 @@ public class DateTimeConverter extends j
         format = _getSimpleDateFormat(pattern, locale);
       }
 
-      if (format instanceof SimpleDateFormat && !forParsing)
+      if (format instanceof SimpleDateFormat)
       {
         SimpleDateFormat simpleFormat = (SimpleDateFormat)format;
-
-        // make sure that we have a 4 digit year for "shortish"
-        // dates
-        // DO NOT CHANGE THE FOLLOWING LINE to "dateStyle";  this
-        // must be retrieved from the instance variable!  (See above)
-        // and we need to apply shortish only if it is of date type or
-        // type is date and time.
-        if (null == pattern && "shortish".equals(getDateStyle()) )
-        {
-          int type = _getType(getType());
-          if (type == _TYPE_DATE || type == _TYPE_BOTH )
+        
+        if (!forParsing)
+        {  
+          // make sure that we have a 4 digit year for "shortish"
+          // dates
+          // DO NOT CHANGE THE FOLLOWING LINE to "dateStyle";  this
+          // must be retrieved from the instance variable!  (See above)
+          // and we need to apply shortish only if it is of date type or
+          // type is date and time.
+          if (null == pattern && "shortish".equals(getDateStyle()) )
           {
-            simpleFormat = _get4YearFormat(simpleFormat, locale);
-            format = simpleFormat;
+            int type = _getType(getType());
+        
+            if (type == _TYPE_DATE || type == _TYPE_BOTH )
+            {
+              simpleFormat = _get4YearFormat(simpleFormat, locale);
+              format = simpleFormat;
+            }
           }
-        }
-
-        Calendar cal;
-        RequestContext reqContext = RequestContext.getCurrentInstance();
-        if (reqContext == null)
+        }//end-if for formatting
+        else
         {
-          cal = null;
-          if(_LOG.isWarning())
+          Calendar cal;
+          RequestContext reqContext = RequestContext.getCurrentInstance();
+          
+          if (reqContext == null)
           {
-            _LOG.warning("NO_REQUESTCONTEXT_TWO_DIGIT_YEAR_START_DEFAULT");
+            cal = null;
+        
+            if(_LOG.isWarning())
+            {
+              _LOG.warning("NO_REQUESTCONTEXT_TWO_DIGIT_YEAR_START_DEFAULT");
+            }
           }
-        }
-        else
-        {
-          cal = new GregorianCalendar(reqContext.getTwoDigitYearStart(), 0, 0);
-        }
-        if (cal != null)
-          simpleFormat.set2DigitYearStart(cal.getTime());
-      }
+          else
+          {
+            cal = new GregorianCalendar(reqContext.getTwoDigitYearStart(), 0, 0);
+          }
+          
+          if (cal != null)
+            simpleFormat.set2DigitYearStart(cal.getTime());
+        }//end-if for parsing
+      }//end-if using SimpleDateFormat
 
       // Bug 2002065
       format.setLenient(false);