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

DateUtils.isSameLocalTime does not work correct

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0, 2.7
    • Component/s: lang.time.*
    • Labels:
      None
    • Environment:

      linux 2.6.32-28, java version "1.6.0_22"

      Description

      Hi, I think I found a bug in the DateUtils class in the method isSameLocalTime.

      Example:
      Calendar a = Calendar.getInstance();
      a.setTimeInMillis(1297364400000L);

      Calendar b = Calendar.getInstance();
      b.setTimeInMillis(1297321200000L);

      Assert.assertFalse(DateUtils.isSameLocalTime(a, b));

      This is because the method compares
      cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR)

      but I think it has to be
      cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chrisatpinguin Christian
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: