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

Print this page

        

*** 57,76 **** * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package java.time.temporal; import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Objects; --- 57,79 ---- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package java.time.chrono; import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; + import java.time.temporal.ChronoField; + import java.time.temporal.TemporalAccessor; + import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Objects;
*** 100,139 **** * <h3>Specification for implementors</h3> * This class is immutable and thread-safe. * * @since 1.8 */ ! public final class ISOChrono extends Chrono<ISOChrono> implements Serializable { /** * Singleton instance of the ISO chronology. */ ! public static final ISOChrono INSTANCE = new ISOChrono(); /** * The singleton instance for the era BCE - 'Before Current Era'. * The 'ISO' part of the name emphasizes that this differs from the BCE * era in the Gregorian calendar system. * This has the numeric value of {@code 0}. */ ! public static final Era<ISOChrono> ERA_BCE = ISOEra.BCE; /** * The singleton instance for the era CE - 'Current Era'. * The 'ISO' part of the name emphasizes that this differs from the CE * era in the Gregorian calendar system. * This has the numeric value of {@code 1}. */ ! public static final Era<ISOChrono> ERA_CE = ISOEra.CE; /** * Serialization version. */ private static final long serialVersionUID = -1440403870442975015L; /** * Restricted constructor. */ ! private ISOChrono() { } /** * Resolve singleton. * --- 103,142 ---- * <h3>Specification for implementors</h3> * This class is immutable and thread-safe. * * @since 1.8 */ ! public final class IsoChronology extends Chronology implements Serializable { /** * Singleton instance of the ISO chronology. */ ! public static final IsoChronology INSTANCE = new IsoChronology(); /** * The singleton instance for the era BCE - 'Before Current Era'. * The 'ISO' part of the name emphasizes that this differs from the BCE * era in the Gregorian calendar system. * This has the numeric value of {@code 0}. */ ! public static final Era ERA_BCE = IsoEra.BCE; /** * The singleton instance for the era CE - 'Current Era'. * The 'ISO' part of the name emphasizes that this differs from the CE * era in the Gregorian calendar system. * This has the numeric value of {@code 1}. */ ! public static final Era ERA_CE = IsoEra.CE; /** * Serialization version. */ private static final long serialVersionUID = -1440403870442975015L; /** * Restricted constructor. */ ! private IsoChronology() { } /** * Resolve singleton. *
*** 145,156 **** //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ISO'. * <p> ! * The ID uniquely identifies the {@code Chrono}. ! * It can be used to lookup the {@code Chrono} using {@link #of(String)}. * * @return the chronology ID - 'ISO' * @see #getCalendarType() */ @Override --- 148,159 ---- //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ISO'. * <p> ! * The ID uniquely identifies the {@code Chronology}. ! * It can be used to lookup the {@code Chronology} using {@link #of(String)}. * * @return the chronology ID - 'ISO' * @see #getCalendarType() */ @Override
*** 161,171 **** /** * Gets the calendar type of the underlying calendar system - 'iso8601'. * <p> * The calendar type is an identifier defined by the * <em>Unicode Locale Data Markup Language (LDML)</em> specification. ! * It can be used to lookup the {@code Chrono} using {@link #of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * * @return the calendar system type - 'iso8601' * @see #getId() --- 164,174 ---- /** * Gets the calendar type of the underlying calendar system - 'iso8601'. * <p> * The calendar type is an identifier defined by the * <em>Unicode Locale Data Markup Language (LDML)</em> specification. ! * It can be used to lookup the {@code Chronology} using {@link #of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * * @return the calendar system type - 'iso8601' * @see #getId()
*** 186,196 **** * @param dayOfMonth the ISO day-of-month * @return the ISO local date, not null * @throws DateTimeException if unable to create the date */ @Override // override with covariant return type ! public LocalDate date(Era<ISOChrono> era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } /** * Obtains an ISO local date from the proleptic-year, month-of-year --- 189,199 ---- * @param dayOfMonth the ISO day-of-month * @return the ISO local date, not null * @throws DateTimeException if unable to create the date */ @Override // override with covariant return type ! public LocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } /** * Obtains an ISO local date from the proleptic-year, month-of-year
*** 217,227 **** * @param dayOfYear the ISO day-of-year * @return the ISO local date, not null * @throws DateTimeException if unable to create the date */ @Override // override with covariant return type ! public LocalDate dateYearDay(Era<ISOChrono> era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } /** * Obtains an ISO local date from the proleptic-year and day-of-year fields. --- 220,230 ---- * @param dayOfYear the ISO day-of-year * @return the ISO local date, not null * @throws DateTimeException if unable to create the date */ @Override // override with covariant return type ! public LocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } /** * Obtains an ISO local date from the proleptic-year and day-of-year fields.
*** 289,298 **** --- 292,302 ---- * @param instant the instant to create the date-time from, not null * @param zone the time-zone, not null * @return the zoned date-time, not null * @throws DateTimeException if the result exceeds the supported range */ + @Override public ZonedDateTime zonedDateTime(Instant instant, ZoneId zone) { return ZonedDateTime.ofInstant(instant, zone); } //-----------------------------------------------------------------------
*** 371,395 **** public boolean isLeapYear(long prolepticYear) { return ((prolepticYear & 3) == 0) && ((prolepticYear % 100) != 0 || (prolepticYear % 400) == 0); } @Override ! public int prolepticYear(Era<ISOChrono> era, int yearOfEra) { ! if (era instanceof ISOEra == false) { ! throw new DateTimeException("Era must be ISOEra"); } ! return (era == ISOEra.CE ? yearOfEra : 1 - yearOfEra); } @Override ! public Era<ISOChrono> eraOf(int eraValue) { ! return ISOEra.of(eraValue); } @Override ! public List<Era<ISOChrono>> eras() { ! return Arrays.<Era<ISOChrono>>asList(ISOEra.values()); } //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) { --- 375,399 ---- public boolean isLeapYear(long prolepticYear) { return ((prolepticYear & 3) == 0) && ((prolepticYear % 100) != 0 || (prolepticYear % 400) == 0); } @Override ! public int prolepticYear(Era era, int yearOfEra) { ! if (era instanceof IsoEra == false) { ! throw new DateTimeException("Era must be IsoEra"); } ! return (era == IsoEra.CE ? yearOfEra : 1 - yearOfEra); } @Override ! public Era eraOf(int eraValue) { ! return IsoEra.of(eraValue); } @Override ! public List<Era> eras() { ! return Arrays.<Era>asList(IsoEra.values()); } //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) {