Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152384

ChronoUnit.MONTHS return wrong result

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      When try to find the number of months between 31/12/2015 and 29/02/2016 it returns 1 instead of 2.
      But when we add 2 months to 31/12/2015 it returns 29/02/2016.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      LocalDate date1 = LocalDate.of(2015, Month.DECEMBER, 31);
      LocalDate date2 = date1.plusMonths(2);
      System.out.println(date2);
      System.out.println(ChronoUnit.MONTHS.between(date1, date2));
      System.out.println(Period.between(date1, date2));

      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: