ZoneId getId() method in Java with Examples
The getId() method of the ZoneId class in Java is used to get the unique time-zone ID which uniquely defines this object.
Syntax:
public String getId(Object obj)
Parameters: This method accepts nothing.
Return value: This method returns the time-zone unique ID.
Below programs illustrate the getId() method:
Program 1:
import java.time.*;
public class GFG {
public static void main(String[] args)
{
ZoneId zoneId
= ZoneId.of( "Europe/Paris" );
System.out.println( "Id: "
+ zoneId.getId());
}
}
|
Program 2:
import java.time.*;
public class GFG {
public static void main(String[] args)
{
ZoneId zoneId
= ZoneId.of( "Asia/Calcutta" );
System.out.println( "Id: "
+ zoneId.getId());
}
}
|
Output:
Id: Asia/Calcutta
Reference:
https://docs.oracle.com/javase/10/docs/api/java/time/ZoneId.html#getId()
Last Updated :
10 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...