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.
lengthOfMonth
has the following syntax.
public int lengthOfMonth()
The following example shows how to use lengthOfMonth
.
import java.time.YearMonth; // w w w. ja v a 2 s . co 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.