YearMonth lengthOfMonth() example
Description
YearMonth lengthOfMonth()
returns the length of the month, taking account of the year.
This returns the length of the month in days. For example, a date in January would return 31.
Syntax
lengthOfMonth
has the following syntax.
public int lengthOfMonth()
Example
The following example shows how to use lengthOfMonth
.
import java.time.YearMonth;
/*from w w w . j av a2 s . c o m*/
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
System.out.println(y.lengthOfMonth());
}
}
The code above generates the following result.