Javatpoint Logo
Javatpoint Logo

Java ZoneId class

Java ZoneId class specifies a time zone identifier and provides a rule for converting between an Instant and a LocalDateTime. It inherits Object class and implements the Serializable interface.


Java ZoneId class declaration

Let's see the declaration of java.time.ZoneId class.

Methods of Java ZoneId

Method Description
String getDisplayName(TextStyle style, Locale locale) It is used to get the textual representation of the zone, such as 'India Time' or '+05:30'.
abstract String getId() It is used to get the unique time-zone ID.
static ZoneId of(String zoneId) It is used to obtain an instance of ZoneId from an ID ensuring that the ID is valid and available for use.
static ZoneId systemDefault() It is used to get the system default time-zone.
boolean equals(Object obj) It is used to check if this time-zone ID is equal to another time-zone ID.

Java ZoneId class Example

Test it Now

Output:

14:28:58.230
17:58:58.230
true

Java ZoneId class Example: systemDefault()

Test it Now

Output:

Asia/Kolkata

Java ZoneId class Example: getId()

Test it Now

Output:

Asia/Kolkata

Java ZoneId class Example: getDisplayName()

Test it Now

Output:

India Time
Next TopicJava ZoneOffset




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA