Java Code Examples for java.time.temporal.TemporalUnit#isSupportedBy()
The following examples show how to use
java.time.temporal.TemporalUnit#isSupportedBy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YearMonth.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this year-month. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code MONTHS} * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == MONTHS || unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 2
Source File: YearMonth.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code MONTHS} * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == MONTHS || unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 3
Source File: ChronoLocalDate.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} date units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isDateBased(); } return unit != null && unit.isSupportedBy(this); }
Example 4
Source File: OffsetDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * <li>{@code DAYS} * <li>{@code WEEKS} * <li>{@code MONTHS} * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override // override for Javadoc public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 5
Source File: ChronoLocalDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 6
Source File: YearMonth.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code MONTHS} * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == MONTHS || unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 7
Source File: ChronoLocalDateTime.java From desugar_jdk_libs with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 8
Source File: ChronoZonedDateTime.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 9
Source File: ChronoLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 10
Source File: OffsetDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * <li>{@code DAYS} * <li>{@code WEEKS} * <li>{@code MONTHS} * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override // override for Javadoc public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 11
Source File: OffsetTime.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this offset-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override // override for Javadoc public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased(); } return unit != null && unit.isSupportedBy(this); }
Example 12
Source File: ChronoLocalDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to or subtracted from this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * The set of supported units is defined by the chronology and normally includes * all {@code ChronoUnit} units except {@code FOREVER}. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override default boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit != FOREVER; } return unit != null && unit.isSupportedBy(this); }
Example 13
Source File: Year.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this year. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 14
Source File: OffsetTime.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this offset-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override // override for Javadoc public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased(); } return unit != null && unit.isSupportedBy(this); }
Example 15
Source File: Year.java From Java8CN with Apache License 2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this year. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 16
Source File: OffsetTime.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override // override for Javadoc public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased(); } return unit != null && unit.isSupportedBy(this); }
Example 17
Source File: Year.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code YEARS} * <li>{@code DECADES} * <li>{@code CENTURIES} * <li>{@code MILLENNIA} * <li>{@code ERAS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; } return unit != null && unit.isSupportedBy(this); }
Example 18
Source File: Instant.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * <li>{@code DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased() || unit == DAYS; } return unit != null && unit.isSupportedBy(this); }
Example 19
Source File: Instant.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * <li>{@code DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased() || unit == DAYS; } return unit != null && unit.isSupportedBy(this); }
Example 20
Source File: Instant.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Checks if the specified unit is supported. * <p> * This checks if the specified unit can be added to, or subtracted from, this date-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * <p> * If the unit is a {@link ChronoUnit} then the query is implemented here. * The supported units are: * <ul> * <li>{@code NANOS} * <li>{@code MICROS} * <li>{@code MILLIS} * <li>{@code SECONDS} * <li>{@code MINUTES} * <li>{@code HOURS} * <li>{@code HALF_DAYS} * <li>{@code DAYS} * </ul> * All other {@code ChronoUnit} instances will return false. * <p> * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.isSupportedBy(Temporal)} * passing {@code this} as the argument. * Whether the unit is supported is determined by the unit. * * @param unit the unit to check, null returns false * @return true if the unit can be added/subtracted, false if not */ @Override public boolean isSupported(TemporalUnit unit) { if (unit instanceof ChronoUnit) { return unit.isTimeBased() || unit == DAYS; } return unit != null && unit.isSupportedBy(this); }