commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r902955 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java
Date Mon, 25 Jan 2010 19:40:38 GMT
Author: sebb
Date: Mon Jan 25 19:40:38 2010
New Revision: 902955

URL: http://svn.apache.org/viewvc?rev=902955&view=rev
Log:
Simplify code (eliminate conditional check) and avoid NPE warning

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java?rev=902955&r1=902954&r2=902955&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java Mon
Jan 25 19:40:38 2010
@@ -312,7 +312,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++) {
 
@@ -323,12 +324,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