commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r1066653 - in /commons/proper/lang/branches/LANG_2_X/src: main/java/org/apache/commons/lang/time/DateUtils.java test/java/org/apache/commons/lang/time/DateUtilsTest.java
Date Wed, 02 Feb 2011 22:02:33 GMT
Author: niallp
Date: Wed Feb  2 22:02:32 2011
New Revision: 1066653

URL: http://svn.apache.org/viewvc?rev=1066653&view=rev
Log:
Port LANG-677 to 2.x branch - DateUtils isSameLocalTime() compares the hour using 12hour Calendar.HOUR
instead of 24hour Calendar.HOUR_OF_DAY - thanks to Christian

Modified:
    commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/DateUtils.java
    commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/DateUtilsTest.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=1066653&r1=1066652&r2=1066653&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
Wed Feb  2 22:02:32 2011
@@ -259,7 +259,7 @@ public class DateUtils {
         return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND) &&
                 cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND) &&
                 cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE) &&
-                cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR) &&
+                cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY) &&
                 cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) &&
                 cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
                 cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&

Modified: commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/DateUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/DateUtilsTest.java?rev=1066653&r1=1066652&r2=1066653&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/DateUtilsTest.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/DateUtilsTest.java
Wed Feb  2 22:02:32 2011
@@ -226,6 +226,14 @@ public class DateUtilsTest extends TestC
         cal2.set(2004, 6, 9, 13, 45, 0);
         cal2.set(Calendar.MILLISECOND, 0);
         assertEquals(true, DateUtils.isSameLocalTime(cal1, cal2));
+
+        Calendar cal3 = Calendar.getInstance();
+        Calendar cal4 = Calendar.getInstance();
+        cal3.set(2004, 6, 9, 4,  0, 0);
+        cal4.set(2004, 6, 9, 16, 0, 0);
+        cal3.set(Calendar.MILLISECOND, 0);
+        cal4.set(Calendar.MILLISECOND, 0);
+        assertFalse("LANG-677", DateUtils.isSameLocalTime(cal3, cal4));
         
         cal2.set(2004, 6, 9, 11, 45, 0);
         assertEquals(false, DateUtils.isSameLocalTime(cal1, cal2));



Mime
View raw message