408 * @throws DateTimeException if the instant exceeds the maximum or minimum instant
409 */
410 private static Instant create(long seconds, int nanoOfSecond) {
411 if ((seconds | nanoOfSecond) == 0) {
412 return EPOCH;
413 }
414 if (seconds < MIN_SECOND || seconds > MAX_SECOND) {
415 throw new DateTimeException("Instant exceeds minimum or maximum instant");
416 }
417 return new Instant(seconds, nanoOfSecond);
418 }
419
420 /**
421 * Constructs an instance of {@code Instant} using seconds from the epoch of
422 * 1970-01-01T00:00:00Z and nanosecond fraction of second.
423 *
424 * @param epochSecond the number of seconds from 1970-01-01T00:00:00Z
425 * @param nanos the nanoseconds within the second, must be positive
426 */
427 private Instant(long epochSecond, int nanos) {
428 super();
429 this.seconds = epochSecond;
430 this.nanos = nanos;
431 }
432
433 //-----------------------------------------------------------------------
434 /**
435 * Checks if the specified field is supported.
436 * <p>
437 * This checks if this instant can be queried for the specified field.
438 * If false, then calling the {@link #range(TemporalField) range},
439 * {@link #get(TemporalField) get} and {@link #with(TemporalField, long)}
440 * methods will throw an exception.
441 * <p>
442 * If the field is a {@link ChronoField} then the query is implemented here.
443 * The supported fields are:
444 * <ul>
445 * <li>{@code NANO_OF_SECOND}
446 * <li>{@code MICRO_OF_SECOND}
447 * <li>{@code MILLI_OF_SECOND}
448 * <li>{@code INSTANT_SECONDS}
|
408 * @throws DateTimeException if the instant exceeds the maximum or minimum instant
409 */
410 private static Instant create(long seconds, int nanoOfSecond) {
411 if ((seconds | nanoOfSecond) == 0) {
412 return EPOCH;
413 }
414 if (seconds < MIN_SECOND || seconds > MAX_SECOND) {
415 throw new DateTimeException("Instant exceeds minimum or maximum instant");
416 }
417 return new Instant(seconds, nanoOfSecond);
418 }
419
420 /**
421 * Constructs an instance of {@code Instant} using seconds from the epoch of
422 * 1970-01-01T00:00:00Z and nanosecond fraction of second.
423 *
424 * @param epochSecond the number of seconds from 1970-01-01T00:00:00Z
425 * @param nanos the nanoseconds within the second, must be positive
426 */
427 private Instant(long epochSecond, int nanos) {
428 this.seconds = epochSecond;
429 this.nanos = nanos;
430 }
431
432 //-----------------------------------------------------------------------
433 /**
434 * Checks if the specified field is supported.
435 * <p>
436 * This checks if this instant can be queried for the specified field.
437 * If false, then calling the {@link #range(TemporalField) range},
438 * {@link #get(TemporalField) get} and {@link #with(TemporalField, long)}
439 * methods will throw an exception.
440 * <p>
441 * If the field is a {@link ChronoField} then the query is implemented here.
442 * The supported fields are:
443 * <ul>
444 * <li>{@code NANO_OF_SECOND}
445 * <li>{@code MICRO_OF_SECOND}
446 * <li>{@code MILLI_OF_SECOND}
447 * <li>{@code INSTANT_SECONDS}
|