commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r905652 - /commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java
Date Tue, 02 Feb 2010 14:44:15 GMT
Author: niallp
Date: Tue Feb  2 14:44:13 2010
New Revision: 905652

URL: http://svn.apache.org/viewvc?rev=905652&view=rev
Log:
Port r902955 to 2.x branch - Simplify code (eliminate conditional check) and avoid NPE warning

Modified:
    commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java

Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java?rev=905652&r1=905651&r2=905652&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java
Tue Feb  2 14:44:13 2010
@@ -328,7 +328,8 @@
             throw new IllegalArgumentException("Date and Patterns must not be null");
         }
         
-        SimpleDateFormat parser = null;
+        SimpleDateFormat parser = new SimpleDateFormat();
+        parser.setLenient(lenient);
         ParsePosition pos = new ParsePosition(0);
         for (int i = 0; i < parsePatterns.length; i++) {
 
@@ -339,12 +340,7 @@
                 pattern = pattern.substring(0, pattern.length() - 1);
             }
             
-            if (i == 0) {
-                parser = new SimpleDateFormat(pattern);
-                parser.setLenient(lenient);
-            } else {
-                parser.applyPattern(pattern); // cannot be null if i != 0
-            }
+            parser.applyPattern(pattern);
             pos.setIndex(0);
 
             String str2 = str;



Mime
View raw message