Lines Matching refs:unit

357      * Checks if the specified unit is supported.
359 * This checks if the specified unit can be added to, or subtracted from, this year-month.
363 * If the unit is a {@link ChronoUnit} then the query is implemented here.
375 * If the unit is not a {@code ChronoUnit}, then the result of this method
378 * Whether the unit is supported is determined by the unit.
380 * @param unit the unit to check, null returns false
381 * @return true if the unit can be added/subtracted, false if not
384 public boolean isSupported(TemporalUnit unit) {
385 if (unit instanceof ChronoUnit) {
386 return unit == MONTHS || unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS;
388 return unit != null && unit.isSupportedBy(this);
751 * in terms of the unit added. If it is not possible to add the amount, because the
752 * unit is not supported or for some other reason, an exception is thrown.
786 * passing {@code this} as the argument. In this case, the unit determines
791 * @param amountToAdd the amount of the unit to add to the result, may be negative
792 * @param unit the unit of the amount to add, not null
795 * @throws UnsupportedTemporalTypeException if the unit is not supported
799 public YearMonth plus(long amountToAdd, TemporalUnit unit) {
800 if (unit instanceof ChronoUnit) {
801 switch ((ChronoUnit) unit) {
809 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
811 return unit.addTo(this, amountToAdd);
881 * in terms of the unit subtracted. If it is not possible to subtract the amount,
882 * because the unit is not supported or for some other reason, an exception is thrown.
889 * @param amountToSubtract the amount of the unit to subtract from the result, may be negative
890 * @param unit the unit of the amount to subtract, not null
893 * @throws UnsupportedTemporalTypeException if the unit is not supported
897 public YearMonth minus(long amountToSubtract, TemporalUnit unit) {
898 return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit));
992 * Calculates the amount of time until another year-month in terms of the specified unit.
1023 * If the unit is not a {@code ChronoUnit}, then the result of this method
1031 * @param unit the unit to measure the amount in, not null
1035 * @throws UnsupportedTemporalTypeException if the unit is not supported
1039 public long until(Temporal endExclusive, TemporalUnit unit) {
1041 if (unit instanceof ChronoUnit) {
1043 switch ((ChronoUnit) unit) {
1051 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
1053 return unit.between(this, end);