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

DateUtils.round doesn't work correct for Calendar.AM_PM

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4
    • 2.5
    • lang.time.*
    • None

    Description

      The provided JUnit-tests test with wrong expected values

      original DateUtilsTest.java
      dateAmPm1 = dateTimeParser.parse("February 3, 2002 01:10:00.000");
      dateAmPm2 = dateTimeParser.parse("February 3, 2002 11:10:00.000");
      dateAmPm3 = dateTimeParser.parse("February 3, 2002 13:10:00.000");
      dateAmPm4 = dateTimeParser.parse("February 3, 2002 19:10:00.000");
      
      assertEquals("truncate ampm-1 failed",
                      dateTimeParser.parse("February 3, 2002 00:00:00.000"),
                      DateUtils.round(dateAmPm1, Calendar.AM_PM));
              assertEquals("truncate ampm-2 failed",
                      dateTimeParser.parse("February 4, 2002 00:00:00.000"),
                      DateUtils.round(dateAmPm2, Calendar.AM_PM));
              assertEquals("truncate ampm-3 failed",
                      dateTimeParser.parse("February 3, 2002 12:00:00.000"),
                      DateUtils.round(dateAmPm3, Calendar.AM_PM));
              assertEquals("truncate ampm-4 failed",
                      dateTimeParser.parse("February 4, 2002 12:00:00.000"),
                      DateUtils.round(dateAmPm4, Calendar.AM_PM));
      

      but expected values must be

      dateTimeParser.parse("February 3, 2002 00:00:00.000");
      dateTimeParser.parse("February 3, 2002 12:00:00.000");
      dateTimeParser.parse("February 3, 2002 12:00:00.000");
      dateTimeParser.parse("February 4, 2002 00:00:00.000");
      

      Also in the junit-comment the word 'truncate' must be replaced with 'round'

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            rfscholte-getthere Robert Scholte
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment