@Override // override with covariant return type public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); }
/** * 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)); }
/** * 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 JapaneseDate dateEpochDay(long epochDay) { return new JapaneseDate(LocalDate.ofEpochDay(epochDay)); }
@Override // override with covariant return type public JapaneseDate date(TemporalAccessor temporal) { if (temporal instanceof JapaneseDate) { return (JapaneseDate) temporal; } return new JapaneseDate(LocalDate.from(temporal)); }
private JapaneseDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new JapaneseDate(newDate)); }
throw new DateTimeException("Requested date is outside bounds of era " + era); return new JapaneseDate(era, yearOfEra, date);
throw new DateTimeException("Requested date is outside bounds of era " + era); return new JapaneseDate(era, yearOfEra, isoDate);