java.time.ZoneId.systemDefault() Method Example



Description

The java.time.ZoneId.systemDefault() method gets the system default time-zone.

Declaration

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

public static ZoneId systemDefault()

Return Value

the zone ID, not null.

Exceptions

  • DateTimeException − if the converted zone ID has an invalid format.

  • ZoneRulesException − if the converted zone region ID cannot be found.

Example

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

package com.tutorialspoint;

import java.time.ZoneId;

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

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

Asia/Calcutta
Advertisements