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

Print this page

        

*** 55,64 **** --- 55,67 ---- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package java.time.temporal; import java.time.Duration; + import java.time.chrono.ChronoLocalDate; + import java.time.chrono.ChronoLocalDateTime; + import java.time.chrono.ChronoZonedDateTime; /** * A standard set of date periods units. * <p> * This set of units provide unit-based access to manipulate a date, time or date-time.
*** 252,284 **** return this.compareTo(DAYS) < 0; } //----------------------------------------------------------------------- @Override ! public boolean isSupported(Temporal temporal) { if (this == FOREVER) { return false; } if (temporal instanceof ChronoLocalDate) { return isDateUnit(); } if (temporal instanceof ChronoLocalDateTime || temporal instanceof ChronoZonedDateTime) { return true; } ! return TemporalUnit.super.isSupported(temporal); } @SuppressWarnings("unchecked") @Override ! public <R extends Temporal> R doPlus(R dateTime, long periodToAdd) { ! return (R) dateTime.plus(periodToAdd, this); } //----------------------------------------------------------------------- @Override ! public <R extends Temporal> SimplePeriod between(R dateTime1, R dateTime2) { ! return new SimplePeriod(dateTime1.periodUntil(dateTime2, this), this); } //----------------------------------------------------------------------- @Override public String toString() { --- 255,287 ---- return this.compareTo(DAYS) < 0; } //----------------------------------------------------------------------- @Override ! public boolean isSupportedBy(Temporal temporal) { if (this == FOREVER) { return false; } if (temporal instanceof ChronoLocalDate) { return isDateUnit(); } if (temporal instanceof ChronoLocalDateTime || temporal instanceof ChronoZonedDateTime) { return true; } ! return TemporalUnit.super.isSupportedBy(temporal); } @SuppressWarnings("unchecked") @Override ! public <R extends Temporal> R addTo(R temporal, long amount) { ! return (R) temporal.plus(amount, this); } //----------------------------------------------------------------------- @Override ! public long between(Temporal temporal1, Temporal temporal2) { ! return temporal1.periodUntil(temporal2, this); } //----------------------------------------------------------------------- @Override public String toString() {