YearMonth from(TemporalAccessor temporal)
creates
an instance of YearMonth from a temporal object.
from
has the following syntax.
public static YearMonth from(TemporalAccessor temporal)
The following example shows how to use from
.
import java.time.LocalDate; import java.time.YearMonth; //w ww . j ava 2 s . c om 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.