ZoneId getDisplayName(TextStyle style, Locale locale) example

Description

ZoneId getDisplayName(TextStyle style, Locale locale) gets the textual representation of the zone, such as 'British Time' or '+02:00'.

Syntax

getDisplayName has the following syntax.


public String getDisplayName(TextStyle style,   Locale locale)

Example

The following example shows how to use getDisplayName.


import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Locale;
//from   w  w w  .ja v a2 s  .  com
public class Main {
  public static void main(String[] args) {
    ZoneId z = ZoneId.systemDefault();
 
    System.out.println(z.getDisplayName(TextStyle.FULL, Locale.CANADA));
  } 
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset