509 /**
510 * Obtains an instance of {@code Duration} using seconds and nanoseconds.
511 *
512 * @param seconds the length of the duration in seconds, positive or negative
513 * @param nanoAdjustment the nanosecond adjustment within the second, from 0 to 999,999,999
514 */
515 private static Duration create(long seconds, int nanoAdjustment) {
516 if ((seconds | nanoAdjustment) == 0) {
517 return ZERO;
518 }
519 return new Duration(seconds, nanoAdjustment);
520 }
521
522 /**
523 * Constructs an instance of {@code Duration} using seconds and nanoseconds.
524 *
525 * @param seconds the length of the duration in seconds, positive or negative
526 * @param nanos the nanoseconds within the second, from 0 to 999,999,999
527 */
528 private Duration(long seconds, int nanos) {
529 super();
530 this.seconds = seconds;
531 this.nanos = nanos;
532 }
533
534 //-----------------------------------------------------------------------
535 /**
536 * Gets the value of the requested unit.
537 * <p>
538 * This returns a value for each of the two supported units,
539 * {@link ChronoUnit#SECONDS SECONDS} and {@link ChronoUnit#NANOS NANOS}.
540 * All other units throw an exception.
541 *
542 * @param unit the {@code TemporalUnit} for which to return the value
543 * @return the long value of the unit
544 * @throws DateTimeException if the unit is not supported
545 * @throws UnsupportedTemporalTypeException if the unit is not supported
546 */
547 @Override
548 public long get(TemporalUnit unit) {
549 if (unit == SECONDS) {
|
509 /**
510 * Obtains an instance of {@code Duration} using seconds and nanoseconds.
511 *
512 * @param seconds the length of the duration in seconds, positive or negative
513 * @param nanoAdjustment the nanosecond adjustment within the second, from 0 to 999,999,999
514 */
515 private static Duration create(long seconds, int nanoAdjustment) {
516 if ((seconds | nanoAdjustment) == 0) {
517 return ZERO;
518 }
519 return new Duration(seconds, nanoAdjustment);
520 }
521
522 /**
523 * Constructs an instance of {@code Duration} using seconds and nanoseconds.
524 *
525 * @param seconds the length of the duration in seconds, positive or negative
526 * @param nanos the nanoseconds within the second, from 0 to 999,999,999
527 */
528 private Duration(long seconds, int nanos) {
529 this.seconds = seconds;
530 this.nanos = nanos;
531 }
532
533 //-----------------------------------------------------------------------
534 /**
535 * Gets the value of the requested unit.
536 * <p>
537 * This returns a value for each of the two supported units,
538 * {@link ChronoUnit#SECONDS SECONDS} and {@link ChronoUnit#NANOS NANOS}.
539 * All other units throw an exception.
540 *
541 * @param unit the {@code TemporalUnit} for which to return the value
542 * @return the long value of the unit
543 * @throws DateTimeException if the unit is not supported
544 * @throws UnsupportedTemporalTypeException if the unit is not supported
545 */
546 @Override
547 public long get(TemporalUnit unit) {
548 if (unit == SECONDS) {
|