ZoneId getDisplayName() method in Java with Examples
The getDisplayName() method of the ZoneId class used to get the textual representation of the zone suitable for presentation to the user such as ‘British Time’ or ‘+02:00’.If no textual mapping is found then the full ID is returned.
Syntax:
public String getDisplayName(TextStyle style, Locale locale)
Parameters: This method accepts two parameters style and locale where style represents the length of the text required and locale represents the locale to use.
Return value: This method returns the text value of the zone.
Below programs illustrate the getDisplayName() method:
Program 1:
// Java program to demonstrate // ZoneId.getDisplayName() method import java.time.*; import java.time.format.TextStyle; import java.util.Locale; public class GFG { public static void main(String[] args) { // create ZoneId object ZoneId zoneId = ZoneId.of("Europe/Paris"); // get Zone id in style TextStyle.SHORT and // Locale = Locale.ENGLISH String response = zoneId.getDisplayName(TextStyle.SHORT, Locale.ENGLISH); // print result System.out.println("ZoneId:" + response); } } |
ZoneId:CET
Program 2:
// Java program to demonstrate // ZoneId.getDisplayName() method import java.time.*; import java.time.format.TextStyle; import java.util.Locale; public class GFG { public static void main(String[] args) { // create ZoneId object ZoneId zoneId = ZoneId.of("Asia/Calcutta"); // get Zone id in style TextStyle.FULL and // Locale = Locale.FRENCH String response = zoneId.getDisplayName(TextStyle.FULL, Locale.FRENCH); // print result System.out.println("ZoneId: " + response); } } |
ZoneId: Inde
Recommended Posts:
- ZoneOffset getDisplayName() method in Java with Examples
- Locale getDisplayName() Method in Java with Examples
- Calendar getDisplayName() Method in Java with Examples
- DayOfWeek getDisplayName() method in Java with Examples
- TimeZone getDisplayName() Method in Java with Examples
- TimeZone getDisplayName(boolean, int) Method in Java with Examples
- ZoneId from() method in Java with Examples
- ZoneId getId() method in Java with Examples
- ZoneId getAvailableZoneIds() method in Java with Examples
- ZoneId normalized() method in Java with Examples
- ZoneId toString() method in Java with Examples
- ZoneId systemDefault() method in Java with Examples
- ZoneId hashCode() method in Java with Examples
- ZoneId ofOffset() method in Java with Examples
- ZoneId getRules() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai



