Lines Matching refs:unit

370      * Checks if the specified unit is supported.
372 * This checks if the specified unit can be added to, or subtracted from, this year.
376 * If the unit is a {@link ChronoUnit} then the query is implemented here.
387 * If the unit is not a {@code ChronoUnit}, then the result of this method
390 * Whether the unit is supported is determined by the unit.
392 * @param unit the unit to check, null returns false
393 * @return true if the unit can be added/subtracted, false if not
396 public boolean isSupported(TemporalUnit unit) {
397 if (unit instanceof ChronoUnit) {
398 return unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS;
400 return unit != null && unit.isSupportedBy(this);
657 * in terms of the unit added. If it is not possible to add the amount, because the
658 * unit is not supported or for some other reason, an exception is thrown.
689 * passing {@code this} as the argument. In this case, the unit determines
694 * @param amountToAdd the amount of the unit to add to the result, may be negative
695 * @param unit the unit of the amount to add, not null
698 * @throws UnsupportedTemporalTypeException if the unit is not supported
702 public Year plus(long amountToAdd, TemporalUnit unit) {
703 if (unit instanceof ChronoUnit) {
704 switch ((ChronoUnit) unit) {
711 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
713 return unit.addTo(this, amountToAdd);
762 * in terms of the unit subtracted. If it is not possible to subtract the amount,
763 * because the unit is not supported or for some other reason, an exception is thrown.
770 * @param amountToSubtract the amount of the unit to subtract from the result, may be negative
771 * @param unit the unit of the amount to subtract, not null
774 * @throws UnsupportedTemporalTypeException if the unit is not supported
778 public Year minus(long amountToSubtract, TemporalUnit unit) {
779 return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit));
860 * Calculates the amount of time until another year in terms of the specified unit.
891 * If the unit is not a {@code ChronoUnit}, then the result of this method
899 * @param unit the unit to measure the amount in, not null
903 * @throws UnsupportedTemporalTypeException if the unit is not supported
907 public long until(Temporal endExclusive, TemporalUnit unit) {
909 if (unit instanceof ChronoUnit) {
911 switch ((ChronoUnit) unit) {
918 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
920 return unit.between(this, end);