
- Java.util Package Classes
- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util Package Extras
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
- 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.util.Calendar.getDisplayName() Method
Description
The java.util.Calendar.getDisplayName() method returns the string representation of the calendar field value in the given style and locale.
Declaration
Following is the declaration for java.util.Calendar.getDisplayName() method
public String getDisplayName(int field,int style,Locale locale)
Parameters
field − the calendar field.
style − the style that will be applied to the string representation
locale − the string representation locale
Return Value
The method returns the string representation of the given field in the given style, or null if no string representation is available.
Exception
IllegalArgumentException − if field or style are invalid, or if this Calendar is non-lenient and any of the fields has invalid values
NullPointerException − if locale is null
Example
The following example shows the usage of java.util.calendar.getDisplayName() method.
package com.tutorialspoint; import java.util.*; public class CalendarGetDisplayNameEx { public static void main(String args[]) { // create objects of locale class Locale object1 = new Locale("GERMAN", "Germany"); Locale object2 = new Locale("FRENCH", "France"); System.out.println("Object1 is : " + object1); System.out.println("Object2 is : " + object2); // get the display name for object1 String objName = object1.getDisplayName(); // print the results System.out.println("Name for object1 : " + objName); // get the display name for object2 objName = object2.getDisplayName(); System.out.println("Name for object2 : " + objName); } }
Let us compile and run the above program, this will produce the following result −
Object1 is : german_GERMANY Object2 is : french_FRANCE Name for object1 : german (GERMANY) Name for object2 : french (FRANCE)