Get the last date of a month in Java
Description
The following code shows how to get the last date of a month.
Example
//from w w w. j a v a 2 s . co m
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
int lastDate = calendar.getActualMaximum(Calendar.DATE);
System.out.println("Date : " + calendar.getTime());
System.out.println("Last Date: " + lastDate);
}
}
The code above generates the following result.