Get last Date of This Month
import java.util.Calendar;
public final class DateTimeUtil {
public static final String tsDefaultFormats[] = { "yyyy-MM-dd HH:mm:ss",
"yyyy-MM-dd", "HH:mm:ss", "HH:mm", "yyyy-MM" };
public static final int getlastDateofThisMonth(int month, int year) {
Calendar calendar = Calendar.getInstance();
if (year > -1) {
calendar.set(Calendar.YEAR, year);
}
if (month > -1) {
month--;
calendar.set(Calendar.MONTH, month);
}
return calendar.getActualMaximum(Calendar.DATE);
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Date Get:
- Day of Week
- Number of days in a month
- Month of year
- Current month name
- Full date time
- Get all attributes from a Calendar
- Get year, month, day, minute, hour, second, milli second from java.util.Date through Calendar
- Get age from a birthday date
- Get Monday
- Get next Sunday
- Get today's date
- Get the last day of a month
- Get date of yesterday
- Get Day-of-Week for a Particular Date
- Get date of last week
- Get date of last month
- Get last Date of This Month
- Get Month in a leap year
- Get start of a month
- Get the end of a month
- Get noon of a day
- Get days since a date
- Get TimeZone
- Get Last day fo previous Month
- Is an hour between an interval
- Is a Year a Leap Year