/** * Combines this year with a month to create a {@code YearMonth}. * <p> * This returns a {@code YearMonth} formed from this year and the specified month. * All possible combinations of year and month are valid. * <p> * This method can be used as part of a chain to produce a date: * <pre> * LocalDate date = year.atMonth(month).atDay(day); * </pre> * * @param month the month-of-year to use, not null * @return the year-month formed from this year and the specified month, not null */ public YearMonth atMonth(Month month) { return YearMonth.of(year, month); }
/** * Combines this year with a month to create a {@code YearMonth}. * <p> * This returns a {@code YearMonth} formed from this year and the specified month. * All possible combinations of year and month are valid. * <p> * This method can be used as part of a chain to produce a date: * <pre> * LocalDate date = year.atMonth(month).atDay(day); * </pre> * * @param month the month-of-year to use, from 1 (January) to 12 (December) * @return the year-month formed from this year and the specified month, not null * @throws DateTimeException if the month is invalid */ public YearMonth atMonth(int month) { return YearMonth.of(year, month); }
/** * Combines this year with a month to create a {@code YearMonth}. * <p> * This returns a {@code YearMonth} formed from this year and the specified month. * All possible combinations of year and month are valid. * <p> * This method can be used as part of a chain to produce a date: * <pre> * LocalDate date = year.atMonth(month).atDay(day); * </pre> * * @param month the month-of-year to use, from 1 (January) to 12 (December) * @return the year-month formed from this year and the specified month, not null * @throws DateTimeException if the month is invalid */ public YearMonth atMonth(int month) { return YearMonth.of(year, month); }
/** * Combines this year with a month to create a {@code YearMonth}. * <p> * This returns a {@code YearMonth} formed from this year and the specified month. * All possible combinations of year and month are valid. * <p> * This method can be used as part of a chain to produce a date: * <pre> * LocalDate date = year.atMonth(month).atDay(day); * </pre> * * @param month the month-of-year to use, not null * @return the year-month formed from this year and the specified month, not null */ public YearMonth atMonth(Month month) { return YearMonth.of(year, month); }
static YearMonth readExternal(DataInput in) throws IOException { int year = in.readInt(); byte month = in.readByte(); return YearMonth.of(year, month); }
static YearMonth readExternal(DataInput in) throws IOException { int year = in.readInt(); byte month = in.readByte(); return YearMonth.of(year, month); }
/** * Obtains an instance of {@code YearMonth} from a year and month. * * @param year the year to represent, from MIN_YEAR to MAX_YEAR * @param month the month-of-year to represent, not null * @return the year-month, not null * @throws DateTimeException if the year value is invalid */ public static YearMonth of(int year, Month month) { Jdk8Methods.requireNonNull(month, "month"); return of(year, month.getValue()); }
/** * Obtains an instance of {@code YearMonth} from a year and month. * * @param year the year to represent, from MIN_YEAR to MAX_YEAR * @param month the month-of-year to represent, not null * @return the year-month, not null * @throws DateTimeException if the year value is invalid */ public static YearMonth of(int year, Month month) { Jdk8Methods.requireNonNull(month, "month"); return of(year, month.getValue()); }
/** * Obtains the current year-month from the specified clock. * <p> * This will query the specified clock to obtain the current year-month. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current year-month, not null */ public static YearMonth now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return YearMonth.of(now.getYear(), now.getMonth()); }
/** * Obtains the current year-month from the specified clock. * <p> * This will query the specified clock to obtain the current year-month. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current year-month, not null */ public static YearMonth now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return YearMonth.of(now.getYear(), now.getMonth()); }
temporal = LocalDate.from(temporal); return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +
temporal = LocalDate.from(temporal); return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +
"Expected array to end."); return YearMonth.of(year, month);