public long getLong(final TemporalField field) { if (field instanceof ChronoField) { if (field == ChronoField.INSTANT_SECONDS) { return millis / MILLIS_PER_SECOND; } else { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } else { return field.getFrom(this); } }
public long getLong(final TemporalField field) { if (field instanceof ChronoField) { if (field == ChronoField.INSTANT_SECONDS) { return millis / MILLIS_PER_SECOND; } else { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } else { return field.getFrom(this); } }
private static void outputLeapSecondDat(OutputStream jos, SortedMap<LocalDate, Byte> leapSeconds) throws IOException { DataOutputStream out = new DataOutputStream(jos); // file version out.writeByte(1); // count out.writeInt(leapSeconds.size() + 1); // first line is fixed in UTC-TAI leap second system, always 10 seconds at 1972-01-01 int offset = 10; out.writeLong(MJD_1972_01_01); out.writeInt(offset); // now treat all the transitions for (Map.Entry<LocalDate, Byte> rule : leapSeconds.entrySet()) { out.writeLong(JulianFields.MODIFIED_JULIAN_DAY.getFrom(rule.getKey())); offset += rule.getValue(); out.writeInt(offset); } out.flush(); }
throw new UnsupportedTemporalTypeException("Unsupported field: " + field); return field.getFrom(this);
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
throw new UnsupportedTemporalTypeException("Unsupported field: " + field); return field.getFrom(this);
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); }
/** * Gets the value of the specified field from this day-of-week as a {@code long}. * <p> * This queries this day-of-week for the value for the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. * <p> * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained * @throws ArithmeticException if numeric overflow occurs */ @Override public long getLong(TemporalField field) { if (field == DAY_OF_WEEK) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }
throw new UnsupportedTemporalTypeException("Unsupported field: " + field); return field.getFrom(this);
/** * Gets the value of the specified field from this date-time as a {@code long}. * <p> * This queries this date-time for the value for the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. * <p> * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained * @throws ArithmeticException if numeric overflow occurs */ @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case INSTANT_SECONDS: return toEpochSecond(); case OFFSET_SECONDS: return getOffset().getTotalSeconds(); } return toLocalDateTime().getLong(field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case ALIGNED_DAY_OF_WEEK_IN_MONTH: case ALIGNED_DAY_OF_WEEK_IN_YEAR: case ALIGNED_WEEK_OF_MONTH: case ALIGNED_WEEK_OF_YEAR: throw new UnsupportedTemporalTypeException("Unsupported field: " + field); case YEAR_OF_ERA: return yearOfEra; case ERA: return era.getValue(); case DAY_OF_YEAR: return getDayOfYear(); } return isoDate.getLong(field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case PROLEPTIC_MONTH: return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); } case YEAR: return getProlepticYear(); case ERA: return (getProlepticYear() >= 1 ? 1 : 0); } return isoDate.getLong(field); } return field.getFrom(this); }
return field.getFrom(this);
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case PROLEPTIC_MONTH: return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); } case YEAR: return getProlepticYear(); case ERA: return (getProlepticYear() >= 1 ? 1 : 0); } return isoDate.getLong(field); } return field.getFrom(this); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case DAY_OF_WEEK: return dayOfWeek.getValue(); case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((dayOfWeek.getValue() - 1) % 7) + 1; case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((dayOfYear - 1) % 7) + 1; case DAY_OF_MONTH: return this.dayOfMonth; case DAY_OF_YEAR: return this.dayOfYear; case EPOCH_DAY: return toEpochDay(); case ALIGNED_WEEK_OF_MONTH: return ((dayOfMonth - 1) / 7) + 1; case ALIGNED_WEEK_OF_YEAR: return ((dayOfYear - 1) / 7) + 1; case MONTH_OF_YEAR: return monthOfYear; case YEAR_OF_ERA: return yearOfEra; case YEAR: return yearOfEra; case ERA: return era.getValue(); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }