Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      The following test code breaks on Harmony. Setting milliseconds to zero alters the day of the month. Output on RI is:

      today time = Tue May 23 14:06:51 BST 2006
      yesterday time = Mon May 22 14:06:51 BST 2006
      day of month before resetting milliseconds = 23
      day of month after resetting milliseconds = 23
      time before resetting seconds = Tue May 23 14:06:51 BST 2006
      time after resetting seconds = Tue May 23 14:06:00 BST 2006

      Output on Harmony is:

      today time = Tue May 23 13:59:39 BST 2006
      yesterday time = Mon May 22 13:59:39 BST 2006
      day of month before resetting milliseconds = 23
      day of month after resetting milliseconds = 22
      time before resetting seconds = Tue May 23 13:59:39 BST 2006
      time after resetting seconds = Mon May 22 13:59:00 BST 2006

      I suspect it might have something to do with the cachedFields?

      import java.util.TimeZone;
      import java.util.Calendar;

      public class Test2 {

      public static void main(String[] args)

      { Calendar today = Calendar.getInstance(); System.err.println("today time = "+today.getTime()); Calendar yesterday = (Calendar)today.clone(); // copy not deep enough? yesterday.add(Calendar.DATE, -1); System.err.println("yesterday time = "+yesterday.getTime()); Calendar broken = (Calendar)today.clone(); System.err.println("day of month before resetting milliseconds = "+ broken.get(Calendar.DAY_OF_MONTH)); broken.set(Calendar.MILLISECOND, 0); System.err.println("day of month after resetting milliseconds = "+ broken.get(Calendar.DAY_OF_MONTH)); System.err.println("time before resetting seconds = "+broken.getTime()); broken.set(Calendar.SECOND, 0); System.err.println("time after resetting seconds = "+broken.getTime()); }

      }

        Activity

        Hide
        Stepan Mishura added a comment -

        Thanks Mark - bug was fixed in LUNI module at r409336.

        Please check that the fix fully resolves your problem.

        Show
        Stepan Mishura added a comment - Thanks Mark - bug was fixed in LUNI module at r409336. Please check that the fix fully resolves your problem.
        Hide
        Mark Hindess added a comment -

        Looks good. Thanks Stepan.

        Show
        Mark Hindess added a comment - Looks good. Thanks Stepan.
        Hide
        Stepan Mishura added a comment -

        Verified by Mark.

        Show
        Stepan Mishura added a comment - Verified by Mark.

          People

          • Assignee:
            Stepan Mishura
            Reporter:
            Mark Hindess
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development