Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4100

clearTime() fails for times in the afternoon

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.7.1
    • 1.7.2, 1.6.9, 1.8-beta-1
    • groovy-jdk
    • None

    Description

      Calendar.clearTime() fails if the time part of the date is in the afternoon.

      The gdk seems to be doing:

      self.clear(Calendar.HOUR_OF_DAY);
      self.clear(Calendar.HOUR);
      

      I think that second line is unnecessary and breaking things.

      Some test code:

      // clearTime works for times in the morning
      def morning = GregorianCalendar.getInstance()
      morning.set(Calendar.AM_PM, Calendar.AM)
      morning.clearTime()
      assert morning.get(Calendar.HOUR_OF_DAY) == 0
      
      // clearTime fails for times in the afternoon
      def afternoon = GregorianCalendar.getInstance()
      afternoon.set(Calendar.AM_PM, Calendar.PM)
      afternoon.clearTime()
      assert afternoon.get(Calendar.HOUR_OF_DAY) == 0  // fails in Groovy 1.7.1
      

      Attachments

        Activity

          People

            paulk Paul King
            gconboy Glen Conboy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: