- 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
Display Month of Year using Java Calendar
For using Calendar class, import the following package.
import java.util.Calendar;
Using the Calendar class, create an object.
Calendar calendar = Calendar.getInstance();
Now, create a string array of the month names.
String[] month = new String[] {"January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December" };
Display the month name.
month[calendar.get(Calendar.MONTH)]
The following is an example.
Example
import java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); String[] month = new String[] {"January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December" }; System.out.println("Current Month = " + month[calendar.get(Calendar.MONTH)]); } }
Output
The following is the output −
Current Month = Dec
- Related Articles
- Get week of month and year using Java Calendar
- Java Program to Display Dates of Calendar Year in Different Format
- Display Day Name of Week using Java Calendar
- Increment a Month using the Calendar Class in Java
- Decrement a Month using the Calendar Class in Java
- Calendar Functions in Python - ( calendar(), month(), isleap()?)
- How to Display Calendar using Python?
- Determine day of week in month from Gregorian Calendar in Java
- Java Program to subtract 1 year from the calendar
- Calendar Functions in Python | Set 1( calendar(), month(), isleap()…)
- Convert day of year to day of month in Java
- Write the difference between calendar year and fiscal year.
- Display two-digit month in Java
- Display four-digit year in Java
- Display two-digit year in Java

Advertisements