YearMonth from(TemporalAccessor temporal) example
Description
YearMonth from(TemporalAccessor temporal)
creates
an instance of YearMonth from a temporal object.
Syntax
from
has the following syntax.
public static YearMonth from(TemporalAccessor temporal)
Example
The following example shows how to use from
.
import java.time.LocalDate;
import java.time.YearMonth;
// www . j a v a 2 s .co m
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.from(LocalDate.now());
System.out.println(y);
}
}
The code above generates the following result.