< prev index next >

src/java.base/share/classes/java/time/YearMonth.java

Print this page

 112  * The ISO-8601 calendar system is the modern civil calendar system used today
 113  * in most of the world. It is equivalent to the proleptic Gregorian calendar
 114  * system, in which today's rules for leap years are applied for all time.
 115  * For most applications written today, the ISO-8601 rules are entirely suitable.
 116  * However, any application that makes use of historical dates, and requires them
 117  * to be accurate will find the ISO-8601 approach unsuitable.
 118  * <p>
 119  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 120  * class; programmers should treat instances that are
 121  * {@linkplain #equals(Object) equal} as interchangeable and should not
 122  * use instances for synchronization, or unpredictable behavior may
 123  * occur. For example, in a future release, synchronization may fail.
 124  * The {@code equals} method should be used for comparisons.
 125  *
 126  * @implSpec
 127  * This class is immutable and thread-safe.
 128  *
 129  * @since 1.8
 130  */
 131 @jdk.internal.ValueBased

 132 public final class YearMonth
 133         implements Temporal, TemporalAdjuster, Comparable<YearMonth>, Serializable {
 134 
 135     /**
 136      * Serialization version.
 137      */
 138     @java.io.Serial
 139     private static final long serialVersionUID = 4183400860270640070L;
 140     /**
 141      * Parser.
 142      */
 143     private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
 144         .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
 145         .appendLiteral('-')
 146         .appendValue(MONTH_OF_YEAR, 2)
 147         .toFormatter();
 148 
 149     /**
 150      * The year.
 151      */

 112  * The ISO-8601 calendar system is the modern civil calendar system used today
 113  * in most of the world. It is equivalent to the proleptic Gregorian calendar
 114  * system, in which today's rules for leap years are applied for all time.
 115  * For most applications written today, the ISO-8601 rules are entirely suitable.
 116  * However, any application that makes use of historical dates, and requires them
 117  * to be accurate will find the ISO-8601 approach unsuitable.
 118  * <p>
 119  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 120  * class; programmers should treat instances that are
 121  * {@linkplain #equals(Object) equal} as interchangeable and should not
 122  * use instances for synchronization, or unpredictable behavior may
 123  * occur. For example, in a future release, synchronization may fail.
 124  * The {@code equals} method should be used for comparisons.
 125  *
 126  * @implSpec
 127  * This class is immutable and thread-safe.
 128  *
 129  * @since 1.8
 130  */
 131 @jdk.internal.ValueBased
 132 @jdk.internal.MigratedValueClass
 133 public final class YearMonth
 134         implements Temporal, TemporalAdjuster, Comparable<YearMonth>, Serializable {
 135 
 136     /**
 137      * Serialization version.
 138      */
 139     @java.io.Serial
 140     private static final long serialVersionUID = 4183400860270640070L;
 141     /**
 142      * Parser.
 143      */
 144     private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
 145         .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
 146         .appendLiteral('-')
 147         .appendValue(MONTH_OF_YEAR, 2)
 148         .toFormatter();
 149 
 150     /**
 151      * The year.
 152      */
< prev index next >