Issue Details (XML | Word | Printable)

Key: LANG-346
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Henri Yandell
Reporter: Ken Dombeck
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons Lang

Dates.round() behaves incorrectly for minutes and seconds

Created: 06/Jul/07 08:06 PM   Updated: 24/Feb/08 04:24 AM
Return to search
Component/s: None
Affects Version/s: 2.2, 2.3
Fix Version/s: 2.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LANG-346-fix.patch 2007-08-08 09:37 PM Henri Yandell 1 kB
Text File Licensed for inclusion in ASF works LANG-346.patch 2007-08-07 07:04 AM Dave Meikle 4 kB
Issue Links:
Duplicate
 

Resolution Date: 09/Aug/07 12:25 AM


 Description  « Hide
Get unexpected output for rounding by minutes or seconds.

public void testRound()
{
Calendar testCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
testCalendar.set(2007, 6, 2, 8, 9, 50);
Date date = testCalendar.getTime();
System.out.println("Before round() " + date);
System.out.println("After round() " + DateUtils.round(date, Calendar.MINUTE));
}

--2.1 produces
Before round() Mon Jul 02 03:09:50 CDT 2007
After round() Mon Jul 02 03:10:00 CDT 2007 – this is what I would expect

--2.2 and 2.3 produces
Before round() Mon Jul 02 03:09:50 CDT 2007
After round() Mon Jul 02 03:01:00 CDT 2007 – this appears to be wrong



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #564053 Thu Aug 09 00:24:59 UTC 2007 bayard Applying the fix and the test patches from LANG-346 - fixes bugs in DateUtils.round() for minutes and seconds. Patch from Dave Meikle
Files Changed
MODIFY /commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java
MODIFY /commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java