src/share/classes/java/time/temporal/ChronoUnit.java

Print this page




 161     /**
 162      * Unit that represents the concept of a century.
 163      * For the ISO calendar system, it is equal to 100 years.
 164      * <p>
 165      * When used with other calendar systems it must correspond to an integral number of days
 166      * and is normally an integral number of years.
 167      */
 168     CENTURIES("Centuries", Duration.ofSeconds(31556952L * 100L)),
 169     /**
 170      * Unit that represents the concept of a millennium.
 171      * For the ISO calendar system, it is equal to 1000 years.
 172      * <p>
 173      * When used with other calendar systems it must correspond to an integral number of days
 174      * and is normally an integral number of years.
 175      */
 176     MILLENNIA("Millennia", Duration.ofSeconds(31556952L * 1000L)),
 177     /**
 178      * Unit that represents the concept of an era.
 179      * The ISO calendar system doesn't have eras thus it is impossible to add
 180      * an era to a date or date-time.
 181      * The estimated duration of the era is artificially defined as {@code 1,000,00,000 Years}.
 182      * <p>
 183      * When used with other calendar systems there are no restrictions on the unit.
 184      */
 185     ERAS("Eras", Duration.ofSeconds(31556952L * 1000_000_000L)),
 186     /**
 187      * Artificial unit that represents the concept of forever.
 188      * This is primarily used with {@link TemporalField} to represent unbounded fields
 189      * such as the year or era.
 190      * The estimated duration of the era is artificially defined as the largest duration
 191      * supported by {@code Duration}.
 192      */
 193     FOREVER("Forever", Duration.ofSeconds(Long.MAX_VALUE, 999_999_999));
 194 
 195     private final String name;
 196     private final Duration duration;
 197 
 198     private ChronoUnit(String name, Duration estimatedDuration) {
 199         this.name = name;
 200         this.duration = estimatedDuration;
 201     }




 161     /**
 162      * Unit that represents the concept of a century.
 163      * For the ISO calendar system, it is equal to 100 years.
 164      * <p>
 165      * When used with other calendar systems it must correspond to an integral number of days
 166      * and is normally an integral number of years.
 167      */
 168     CENTURIES("Centuries", Duration.ofSeconds(31556952L * 100L)),
 169     /**
 170      * Unit that represents the concept of a millennium.
 171      * For the ISO calendar system, it is equal to 1000 years.
 172      * <p>
 173      * When used with other calendar systems it must correspond to an integral number of days
 174      * and is normally an integral number of years.
 175      */
 176     MILLENNIA("Millennia", Duration.ofSeconds(31556952L * 1000L)),
 177     /**
 178      * Unit that represents the concept of an era.
 179      * The ISO calendar system doesn't have eras thus it is impossible to add
 180      * an era to a date or date-time.
 181      * The estimated duration of the era is artificially defined as {@code 1,000,000,000 Years}.
 182      * <p>
 183      * When used with other calendar systems there are no restrictions on the unit.
 184      */
 185     ERAS("Eras", Duration.ofSeconds(31556952L * 1000_000_000L)),
 186     /**
 187      * Artificial unit that represents the concept of forever.
 188      * This is primarily used with {@link TemporalField} to represent unbounded fields
 189      * such as the year or era.
 190      * The estimated duration of the era is artificially defined as the largest duration
 191      * supported by {@code Duration}.
 192      */
 193     FOREVER("Forever", Duration.ofSeconds(Long.MAX_VALUE, 999_999_999));
 194 
 195     private final String name;
 196     private final Duration duration;
 197 
 198     private ChronoUnit(String name, Duration estimatedDuration) {
 199         this.name = name;
 200         this.duration = estimatedDuration;
 201     }