Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-346

Dates.round() behaves incorrectly for minutes and seconds

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2, 2.3
    • Fix Version/s: 2.4
    • Component/s: lang.time.*
    • Labels:
      None

      Description

      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

        Attachments

        1. LANG-346.patch
          4 kB
          Dave Meikle
        2. LANG-346-fix.patch
          1 kB
          Henri Yandell

          Issue Links

            Activity

              People

              • Assignee:
                bayard Henri Yandell
                Reporter:
                kdombeck Ken Dombeck
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: