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

(cal) API: Add a public, parameterless method called isLeapYear() to GregorianCalendar

XMLWordPrintable

      When a GregorianCalendar object is created, it should be easy to obtain information from it, without the need to specify values from the object again.

      Actually, there is only one leap year method in GregorianCalendar:

          public boolean isLeapYear(int year)

      Therefore, the code looks suboptimal, if you want to obtain the leap year information from the GregorianCalendar object:

          GregorianCalendar g = new GregorianCalendar();
          boolean b = g.isLeapYear(g.get(Calendar.YEAR));

      A more elegant way would be:

          GregorianCalendar g = new GregorianCalendar();
          boolean b = g.isLeapYear();

      That requires to add a parameterless method to the java.util.GregorianCalendar:

         public boolean isLeapYear()

      ###@###.### 2005-1-24 14:19:32 GMT

            naoto Naoto Sato
            jloefflm Johann Löfflmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: