/** * 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 $month the month-of-year to use, not null * @return YearMonth Year the year-month formed from this year and the specified month, not null */ public function atMonth(Month $month) { return YearMonth::ofMonth($this->year, $month); }
public function test_factory_intsMonth_nullMonth() { TestHelper::assertNullException($this, function () { YearMonth::ofMonth(2008, null); }); }
/** * 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 $clock the clock to use, not null * @return YearMonth the current year-month, not null */ public static function nowOf(Clock $clock) { $now = LocalDate::nowOf($clock); // called once return YearMonth::ofMonth($now->getYear(), $now->getMonth()); }