test/java/time/tck/java/time/chrono/CopticDate.java

Print this page

        

*** 85,95 **** * * <h4>Implementation notes</h4> * This class is immutable and thread-safe. */ public final class CopticDate ! implements ChronoLocalDate<CopticDate>, Serializable { /** * Serialization version. */ private static final long serialVersionUID = -7920528871688876868L; --- 85,95 ---- * * <h4>Implementation notes</h4> * This class is immutable and thread-safe. */ public final class CopticDate ! implements ChronoLocalDate, Serializable { /** * Serialization version. */ private static final long serialVersionUID = -7920528871688876868L;
*** 200,210 **** case YEAR_OF_ERA: return (prolepticYear <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE)); // TODO } return getChronology().range(f); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @Override --- 200,210 ---- case YEAR_OF_ERA: return (prolepticYear <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE)); // TODO } return getChronology().range(f); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); } @Override
*** 222,232 **** case MONTH_OF_YEAR: return month; case YEAR_OF_ERA: return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); case YEAR: return prolepticYear; case ERA: return (prolepticYear >= 1 ? 1 : 0); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @Override --- 222,232 ---- case MONTH_OF_YEAR: return month; case YEAR_OF_ERA: return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); case YEAR: return prolepticYear; case ERA: return (prolepticYear >= 1 ? 1 : 0); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); } @Override
*** 247,257 **** case MONTH_OF_YEAR: return resolvePreviousValid(prolepticYear, nvalue, day); case YEAR_OF_ERA: return resolvePreviousValid(prolepticYear >= 1 ? nvalue : 1 - nvalue, month, day); case YEAR: return resolvePreviousValid(nvalue, month, day); case ERA: return resolvePreviousValid(1 - prolepticYear, month, day); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } //----------------------------------------------------------------------- --- 247,257 ---- case MONTH_OF_YEAR: return resolvePreviousValid(prolepticYear, nvalue, day); case YEAR_OF_ERA: return resolvePreviousValid(prolepticYear >= 1 ? nvalue : 1 - nvalue, month, day); case YEAR: return resolvePreviousValid(nvalue, month, day); case ERA: return resolvePreviousValid(1 - prolepticYear, month, day); } ! throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.adjustInto(this, newValue); } //-----------------------------------------------------------------------
*** 266,276 **** case YEARS: return plusYears(amountToAdd); case DECADES: return plusYears(Math.multiplyExact(amountToAdd, 10)); case CENTURIES: return plusYears(Math.multiplyExact(amountToAdd, 100)); case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); } ! throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } //----------------------------------------------------------------------- --- 266,276 ---- case YEARS: return plusYears(amountToAdd); case DECADES: return plusYears(Math.multiplyExact(amountToAdd, 10)); case CENTURIES: return plusYears(Math.multiplyExact(amountToAdd, 100)); case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); } ! throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); } return unit.addTo(this, amountToAdd); } //-----------------------------------------------------------------------
*** 295,320 **** } return CopticDate.ofEpochDay(Math.addExact(toEpochDay(), days)); } @Override ! public long periodUntil(Temporal endDateTime, TemporalUnit unit) { if (endDateTime instanceof ChronoLocalDate == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } ! ChronoLocalDate<?> end = (ChronoLocalDate<?>) endDateTime; if (getChronology().equals(end.getChronology()) == false) { throw new DateTimeException("Unable to calculate period between two different chronologies"); } if (unit instanceof ChronoUnit) { ! return LocalDate.from(this).periodUntil(end, unit); // TODO: this is wrong } return unit.between(this, endDateTime); } @Override ! public Period periodUntil(ChronoLocalDate<?> endDate) { // TODO: untested CopticDate end = (CopticDate) getChronology().date(endDate); long totalMonths = (end.prolepticYear - this.prolepticYear) * 13 + (end.month - this.month); // safe int days = end.day - this.day; if (totalMonths > 0 && days < 0) { --- 295,320 ---- } return CopticDate.ofEpochDay(Math.addExact(toEpochDay(), days)); } @Override ! public long until(Temporal endDateTime, TemporalUnit unit) { if (endDateTime instanceof ChronoLocalDate == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } ! ChronoLocalDate end = (ChronoLocalDate) endDateTime; if (getChronology().equals(end.getChronology()) == false) { throw new DateTimeException("Unable to calculate period between two different chronologies"); } if (unit instanceof ChronoUnit) { ! return LocalDate.from(this).until(end, unit); // TODO: this is wrong } return unit.between(this, endDateTime); } @Override ! public Period until(ChronoLocalDate endDate) { // TODO: untested CopticDate end = (CopticDate) getChronology().date(endDate); long totalMonths = (end.prolepticYear - this.prolepticYear) * 13 + (end.month - this.month); // safe int days = end.day - this.day; if (totalMonths > 0 && days < 0) {