private static JapaneseDate getJapaneseDate(Date date) { if (date != null) { return JapaneseDate.from(date.toLocalDate()); } return null; }
@Override protected ChronoLocalDate chronoLocalDateOf(final JapaneseEra era, final int prolepticYear, final int month, final int dayOfMonth) { return JapaneseDate.of(era, prolepticYear, month, dayOfMonth); }
@Override public void setNonNullParameter(PreparedStatement ps, int i, JapaneseDate parameter, JdbcType jdbcType) throws SQLException { ps.setDate(i, Date.valueOf(LocalDate.ofEpochDay(parameter.toEpochDay()))); }
@Override protected JapaneseDate getReferenceValue(Clock reference) { return JapaneseDate.now( reference ); }
@Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { ChronoField f = (ChronoField) field; switch (f) { case DAY_OF_YEAR: return actualRange(Calendar.DAY_OF_YEAR); case YEAR_OF_ERA: return actualRange(Calendar.YEAR); } return getChronology().range(f); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); }
@Override // override with covariant return type public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); }
@Override protected JapaneseDate getReferenceValue(Clock reference) { return JapaneseDate.now( reference ); }
/** * Obtains the current {@code JapaneseDate} from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@linkplain Clock dependency injection}. * * @param clock the clock to use, not null * @return the current date, not null * @throws DateTimeException if the current date cannot be obtained */ public static JapaneseDate now(Clock clock) { return new JapaneseDate(LocalDate.now(clock)); }
public static JapaneseDate from(TemporalAccessor temporal) { return JapaneseDate.from(temporal); }
@Override protected ChronoLocalDate chronoLocalDateOf(final JapaneseEra era, final int prolepticYear, final int month, final int dayOfMonth) { return JapaneseDate.of(era, prolepticYear, month, dayOfMonth); }
@Override protected JapaneseDate getReferenceValue(Clock reference) { return JapaneseDate.now( reference ); }
/** * Obtains a {@code JapaneseDate} representing a date in the Japanese calendar * system from the proleptic-year, month-of-year and day-of-month fields. * <p> * This returns a {@code JapaneseDate} with the specified fields. * The day must be valid for the year and month, otherwise an exception will be thrown. * <p> * The Japanese proleptic year, month and day-of-month are the same as those * in the ISO calendar system. They are not reset when the era changes. * * @param prolepticYear the Japanese proleptic-year * @param month the Japanese month-of-year, from 1 to 12 * @param dayOfMonth the Japanese day-of-month, from 1 to 31 * @return the date in Japanese calendar system, not null * @throws DateTimeException if the value of any field is out of range, * or if the day-of-month is invalid for the month-year */ public static JapaneseDate of(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); }
@Override public void setNonNullParameter(PreparedStatement ps, int i, JapaneseDate parameter, JdbcType jdbcType) throws SQLException { ps.setDate(i, Date.valueOf(LocalDate.ofEpochDay(parameter.toEpochDay()))); }
private static JapaneseDate getJapaneseDate(Date date) { if (date != null) { return JapaneseDate.from(date.toLocalDate()); } return null; }
@Override protected ChronoLocalDate chronoLocalDateOf(final JapaneseEra era, final int prolepticYear, final int month, final int dayOfMonth) { return JapaneseDate.of(era, prolepticYear, month, dayOfMonth); }
@Override protected JapaneseDate getReferenceValue(Clock reference) { return JapaneseDate.now( reference ); }
@Override // override with covariant return type public JapaneseDate date(TemporalAccessor temporal) { if (temporal instanceof JapaneseDate) { return (JapaneseDate) temporal; } return new JapaneseDate(LocalDate.from(temporal)); }
case "gregory": getDate = i -> i; break; case "buddhist": getDate = i -> ThaiBuddhistDate.from(i); break; case "japanese": getDate = i -> JapaneseDate.from(i) ; break; default: getDate = i -> i; break;
@Override protected ChronoLocalDate chronoLocalDateOf(final JapaneseEra era, final int prolepticYear, final int month, final int dayOfMonth) { return JapaneseDate.of(era, prolepticYear, month, dayOfMonth); }
public static JapaneseDate now(Clock clock) { return JapaneseDate.now(clock); }