- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the last day of month in Java
The getActualMaximum() method returns the maximum value that the specified calendar field could have, based on the time value of this Calendar.
Import the following package to work with Calendar class in Java,
import java.util.Calendar;
Create a calendar object.
Calendar cal = Calendar.getInstance();
Use the getActualMaximum() method to get the last day of the month.
int res = cal.getActualMaximum(Calendar.DATE);
The following is an example.
Example
import java.util.Calendar; public class Main { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); int res = cal.getActualMaximum(Calendar.DATE); System.out.println("Today's Date = " + cal.getTime()); System.out.println("Last Date of the current month = " + res); } }
Output
Today's Date = Mon Nov 19 13:48:18 UTC 2018 Last Date of the current month = 30
- Related Articles
- Java Program to get day of week for the last day of each month in 2019
- How to get last day of the current month in MySQL?
- How to get last day of the previous month in MySQL?
- How to get last day of the next month in MySQL?
- How to get last day of a month in Python?
- Java Program to adjust LocalDate to last Day of Month with TemporalAdjusters class
- How to get the day of the month in JavaScript?
- Convert day of year to day of month in Java
- How to display first day and last day of the month from date records in MySQL?
- How to get current day, month and year in Java 8?
- Display two-digit day of the month in Java
- How to get the first day of next month in MySQL?
- How to get a Date from year, month and day in Java?
- Python Pandas - Indicate whether the date in DateTimeIndex is the last day of the month
- How to get the first day of the current month in MySQL?

Advertisements