< prev index next >

src/java.base/share/classes/java/time/chrono/IsoChronology.java

Print this page




 116  * <li>day-of-year - There are 365 days in a standard ISO year and 366 in a leap year.
 117  *  The days are numbered from 1 to 365 or 1 to 366.
 118  * <li>leap-year - Leap years occur every 4 years, except where the year is divisble by 100 and not divisble by 400.
 119  * </ul>
 120  *
 121  * @implSpec
 122  * This class is immutable and thread-safe.
 123  *
 124  * @since 1.8
 125  */
 126 public final class IsoChronology extends AbstractChronology implements Serializable {
 127 
 128     /**
 129      * Singleton instance of the ISO chronology.
 130      */
 131     public static final IsoChronology INSTANCE = new IsoChronology();
 132 
 133     /**
 134      * Serialization version.
 135      */

 136     private static final long serialVersionUID = -1440403870442975015L;
 137 
 138     private static final long DAYS_0000_TO_1970 = (146097 * 5L) - (30L * 365L + 7L); // taken from LocalDate
 139 
 140     /**
 141      * Restricted constructor.
 142      */
 143     private IsoChronology() {
 144     }
 145 
 146     //-----------------------------------------------------------------------
 147     /**
 148      * Gets the ID of the chronology - 'ISO'.
 149      * <p>
 150      * The ID uniquely identifies the {@code Chronology}.
 151      * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}.
 152      *
 153      * @return the chronology ID - 'ISO'
 154      * @see #getCalendarType()
 155      */


 672      * @return the ISO period, not null
 673      */
 674     @Override  // override with covariant return type
 675     public Period period(int years, int months, int days) {
 676         return Period.of(years, months, days);
 677     }
 678 
 679     //-----------------------------------------------------------------------
 680     /**
 681      * Writes the Chronology using a
 682      * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
 683      * @serialData
 684      * <pre>
 685      *  out.writeByte(1);     // identifies a Chronology
 686      *  out.writeUTF(getId());
 687      * </pre>
 688      *
 689      * @return the instance of {@code Ser}, not null
 690      */
 691     @Override

 692     Object writeReplace() {
 693         return super.writeReplace();
 694     }
 695 
 696     /**
 697      * Defend against malicious streams.
 698      *
 699      * @param s the stream to read
 700      * @throws InvalidObjectException always
 701      */

 702     private void readObject(ObjectInputStream s) throws InvalidObjectException {
 703         throw new InvalidObjectException("Deserialization via serialization delegate");
 704     }
 705 }


 116  * <li>day-of-year - There are 365 days in a standard ISO year and 366 in a leap year.
 117  *  The days are numbered from 1 to 365 or 1 to 366.
 118  * <li>leap-year - Leap years occur every 4 years, except where the year is divisble by 100 and not divisble by 400.
 119  * </ul>
 120  *
 121  * @implSpec
 122  * This class is immutable and thread-safe.
 123  *
 124  * @since 1.8
 125  */
 126 public final class IsoChronology extends AbstractChronology implements Serializable {
 127 
 128     /**
 129      * Singleton instance of the ISO chronology.
 130      */
 131     public static final IsoChronology INSTANCE = new IsoChronology();
 132 
 133     /**
 134      * Serialization version.
 135      */
 136     @java.io.Serial
 137     private static final long serialVersionUID = -1440403870442975015L;
 138 
 139     private static final long DAYS_0000_TO_1970 = (146097 * 5L) - (30L * 365L + 7L); // taken from LocalDate
 140 
 141     /**
 142      * Restricted constructor.
 143      */
 144     private IsoChronology() {
 145     }
 146 
 147     //-----------------------------------------------------------------------
 148     /**
 149      * Gets the ID of the chronology - 'ISO'.
 150      * <p>
 151      * The ID uniquely identifies the {@code Chronology}.
 152      * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}.
 153      *
 154      * @return the chronology ID - 'ISO'
 155      * @see #getCalendarType()
 156      */


 673      * @return the ISO period, not null
 674      */
 675     @Override  // override with covariant return type
 676     public Period period(int years, int months, int days) {
 677         return Period.of(years, months, days);
 678     }
 679 
 680     //-----------------------------------------------------------------------
 681     /**
 682      * Writes the Chronology using a
 683      * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
 684      * @serialData
 685      * <pre>
 686      *  out.writeByte(1);     // identifies a Chronology
 687      *  out.writeUTF(getId());
 688      * </pre>
 689      *
 690      * @return the instance of {@code Ser}, not null
 691      */
 692     @Override
 693     @java.io.Serial
 694     Object writeReplace() {
 695         return super.writeReplace();
 696     }
 697 
 698     /**
 699      * Defend against malicious streams.
 700      *
 701      * @param s the stream to read
 702      * @throws InvalidObjectException always
 703      */
 704     @java.io.Serial
 705     private void readObject(ObjectInputStream s) throws InvalidObjectException {
 706         throw new InvalidObjectException("Deserialization via serialization delegate");
 707     }
 708 }
< prev index next >