- 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
Java Program to list Short Month Names
To list short months, use the getShortMonths() from the DateFormatSymbols class in Java.
DateFormatSymbols is a class for encapsulating localizable date-time formatting data.
Get short month names in an array
String[] months = new DateFormatSymbols().getShortMonths();
Display the months
for (int i = 0; i < months.length - 1; i++) { String month = months[i]; System.out.println("Month ["+i+"] = " + month); }
The following is an example −
Example
import java.text.DateFormatSymbols; public class Demo { public static void main(String[] args) { // short months String[] months = new DateFormatSymbols().getShortMonths(); for (int i = 0; i < months.length - 1; i++) { String month = months[i]; System.out.println("Month ["+i+"] = " + month); } } }
Output
Month [0] = Jan Month [1] = Feb Month [2] = Mar Month [3] = Apr Month [4] = May Month [5] = Jun Month [6] = Jul Month [7] = Aug Month [8] = Sep Month [9] = Oct Month [10] = Nov Month [11] = Dec
- Related Articles
- Java Program to list Short Weekday Names
- Java Program to list Weekday names
- Java Program to sort Short array
- Java Program to compare Two Java short Arrays
- Java Program to convert String to short primitive
- Java Program to display previous month from GregorianCalendar
- Java Program to format Month in MMMM format
- Java Program to fill elements in a short array
- Java Program to get current date, year and month
- Java Program to get first Friday in a month
- Python Program to Sort A List Of Names By Last Name
- Convert short primitive type to Short object in Java
- Java Program to display date with day name in short format
- Convert Java String to Short in Java
- MySQL DATE_FORMAT '%M' is used for short month?

Advertisements