java.time.ZoneId.toString() Method Example



Description

The java.time.ZoneId.toString() method outputs this zone as a String, using the ID.

Declaration

Following is the declaration for java.time.ZoneId.toString() method.

public static ZoneId toString()

Return Value

a string representation of this time-zone ID, not null.

Example

The following example shows the usage of java.time.ZoneId.toString() method.

package com.tutorialspoint;

import java.time.ZoneId;

public class ZoneIdDemo {
   public static void main(String[] args) {
 
      System.out.println(ZoneId.systemDefault().toString());  
   }
}

Let us compile and run the above program, this will produce the following result −

Asia/Calcutta
Advertisements