Author: niallp Date: Wed Feb 2 21:55:15 2011 New Revision: 1066645 URL: http://svn.apache.org/viewvc?rev=1066645&view=rev Log: LANG-677 DateUtils isSameLocalTime() compares the hour using 12hour Calendar.HOUR instead of 24hour Calendar.HOUR_OF_DAY - thanks to Christian
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.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=1066645&r1=1066644&r2=1066645&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 Wed Feb 2 21:55:15 2011 @@ -262,7 +262,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/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java?rev=1066645&r1=1066644&r2=1066645&view=diff ============================================================================== --- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java (original) +++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java Wed Feb 2 21:55:15 2011 @@ -227,6 +227,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));