< prev index next >

src/java.base/share/classes/java/time/Duration.java

Print this page
8213497: "period" related typos in Duration.java
Reviewed-by: scolebourne
Contributed-by: Kurt Kluever <kak@google.com>

*** 301,311 **** * be {@link ChronoUnit#DAYS} which is treated as 24 hours. Other units throw an exception. * * @param amount the amount of the duration, measured in terms of the unit, positive or negative * @param unit the unit that the duration is measured in, must have an exact duration, not null * @return a {@code Duration}, not null ! * @throws DateTimeException if the period unit has an estimated duration * @throws ArithmeticException if a numeric overflow occurs */ public static Duration of(long amount, TemporalUnit unit) { return ZERO.plus(amount, unit); } --- 301,311 ---- * be {@link ChronoUnit#DAYS} which is treated as 24 hours. Other units throw an exception. * * @param amount the amount of the duration, measured in terms of the unit, positive or negative * @param unit the unit that the duration is measured in, must have an exact duration, not null * @return a {@code Duration}, not null ! * @throws DateTimeException if the unit has an estimated duration * @throws ArithmeticException if a numeric overflow occurs */ public static Duration of(long amount, TemporalUnit unit) { return ZERO.plus(amount, unit); }
*** 348,358 **** * string produced by {@code toString()}. The formats accepted are based * on the ISO-8601 duration format {@code PnDTnHnMn.nS} with days * considered to be exactly 24 hours. * <p> * The string starts with an optional sign, denoted by the ASCII negative ! * or positive symbol. If negative, the whole period is negated. * The ASCII letter "P" is next in upper or lower case. * There are then four sections, each consisting of a number and a suffix. * The sections have suffixes in ASCII of "D", "H", "M" and "S" for * days, hours, minutes and seconds, accepted in upper or lower case. * The suffixes must occur in order. The ASCII letter "T" must occur before --- 348,358 ---- * string produced by {@code toString()}. The formats accepted are based * on the ISO-8601 duration format {@code PnDTnHnMn.nS} with days * considered to be exactly 24 hours. * <p> * The string starts with an optional sign, denoted by the ASCII negative ! * or positive symbol. If negative, the whole duration is negated. * The ASCII letter "P" is next in upper or lower case. * There are then four sections, each consisting of a number and a suffix. * The sections have suffixes in ASCII of "D", "H", "M" and "S" for * days, hours, minutes and seconds, accepted in upper or lower case. * The suffixes must occur in order. The ASCII letter "T" must occur before
*** 472,482 **** * <p> * The specified temporal objects must support the {@link ChronoUnit#SECONDS SECONDS} unit. * For full accuracy, either the {@link ChronoUnit#NANOS NANOS} unit or the * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field should be supported. * <p> ! * The result of this method can be a negative period if the end is before the start. * To guarantee to obtain a positive duration call {@link #abs()} on the result. * * @param startInclusive the start instant, inclusive, not null * @param endExclusive the end instant, exclusive, not null * @return a {@code Duration}, not null --- 472,482 ---- * <p> * The specified temporal objects must support the {@link ChronoUnit#SECONDS SECONDS} unit. * For full accuracy, either the {@link ChronoUnit#NANOS NANOS} unit or the * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field should be supported. * <p> ! * The result of this method can be a negative duration if the end is before the start. * To guarantee to obtain a positive duration call {@link #abs()} on the result. * * @param startInclusive the start instant, inclusive, not null * @param endExclusive the end instant, exclusive, not null * @return a {@code Duration}, not null
*** 651,661 **** * nano-of-second part of this duration. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the seconds to represent, may be negative ! * @return a {@code Duration} based on this period with the requested seconds, not null */ public Duration withSeconds(long seconds) { return create(seconds, nanos); } --- 651,661 ---- * nano-of-second part of this duration. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the seconds to represent, may be negative ! * @return a {@code Duration} based on this duration with the requested seconds, not null */ public Duration withSeconds(long seconds) { return create(seconds, nanos); }
*** 666,676 **** * seconds part of this duration. * <p> * This instance is immutable and unaffected by this method call. * * @param nanoOfSecond the nano-of-second to represent, from 0 to 999,999,999 ! * @return a {@code Duration} based on this period with the requested nano-of-second, not null * @throws DateTimeException if the nano-of-second is invalid */ public Duration withNanos(int nanoOfSecond) { NANO_OF_SECOND.checkValidIntValue(nanoOfSecond); return create(seconds, nanoOfSecond); --- 666,676 ---- * seconds part of this duration. * <p> * This instance is immutable and unaffected by this method call. * * @param nanoOfSecond the nano-of-second to represent, from 0 to 999,999,999 ! * @return a {@code Duration} based on this duration with the requested nano-of-second, not null * @throws DateTimeException if the nano-of-second is invalid */ public Duration withNanos(int nanoOfSecond) { NANO_OF_SECOND.checkValidIntValue(nanoOfSecond); return create(seconds, nanoOfSecond);
< prev index next >