/** * Combines this year with a month-day to create a {@code LocalDate}. * <p> * This returns a {@code LocalDate} formed from this year and the specified month-day. * <p> * A month-day of February 29th will be adjusted to February 28th in the resulting * date if the year is not a leap year. * * @param MonthDay $monthDay the month-day to use, not null * @return LocalDate the local date formed from this year and the specified month-day, not null */ public function atMonthDay(MonthDay $monthDay) { return $monthDay->atYear($this->year); }
/** * Obtains the current month-day from the specified clock. * <p> * This will query the specified clock to obtain the current month-day. * 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 MonthDay the current month-day, not null */ public static function nowOf(Clock $clock) { $now = LocalDate::nowOf($clock); // called once return MonthDay::ofMonth($now->getMonth(), $now->getDayOfMonth()); }
/** * @dataProvider provider_sampleToString */ public function test_toString($m, $d, $expected) { $test = MonthDay::of($m, $d); $str = $test->__toString(); $this->assertEquals($expected, $str); }
function data_atMonthDay() { return [[Year::of(2008), MonthDay::of(6, 30), LocalDate::of(2008, 6, 30)], [Year::of(2008), MonthDay::of(2, 29), LocalDate::of(2008, 2, 29)], [Year::of(2009), MonthDay::of(2, 29), LocalDate::of(2009, 2, 28)]]; }