YearMonth toString() example
Description
YearMonth toString()
outputs this year-month as a String, such
as 2014-12. The output will be in the format uuuu-MM:
Syntax
toString
has the following syntax.
public String toString()
Example
The following example shows how to use toString
.
import java.time.YearMonth;
/*from w w w . ja v a2 s . c o m*/
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
System.out.println(y.toString());
}
}
The code above generates the following result.