diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java index f4d80ecd0..9a24c00fa 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java @@ -848,8 +848,8 @@ public class DateUtils { * *

For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar - * 2002 13:00:00.000. If this was passed with MONTH, it would - * return 1 Mar 2002 0:00:00.000.

+ * 2002 14:00:00.000. If this was passed with MONTH, it would + * return 1 Apr 2002 0:00:00.000.

* * @param date the date to work with * @param field the field from Calendar diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index 032b0b184..68094f9e9 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -1177,6 +1177,18 @@ public class DateUtilsTest extends TestCase { * Tests various values with the ceiling method */ public void testCeil() throws Exception { + // test javadoc + assertEquals("ceiling javadoc-1 failed", + dateTimeParser.parse("March 28, 2002 14:00:00.000"), + DateUtils.ceiling( + dateTimeParser.parse("March 28, 2002 13:45:01.231"), + Calendar.HOUR)); + assertEquals("ceiling javadoc-2 failed", + dateTimeParser.parse("April 1, 2002 00:00:00.000"), + DateUtils.ceiling( + dateTimeParser.parse("March 28, 2002 13:45:01.231"), + Calendar.MONTH)); + // tests public static Date ceiling(Date date, int field) assertEquals("ceiling year-1 failed", dateParser.parse("January 1, 2003"),