Java Utility Library

Java TimeZone - useDaylightTime() Method



The java.util.TimeZone.useDaylightTime() method is used to check if this TimeZone uses Daylight Saving Time.

Syntax

public abstract boolean useDaylightTime()

Parameters

No parameter is required.

Return Value

Returns true if this TimeZone uses Daylight Saving Time, false, otherwise.

Exception

NA

Example:

The example below explains how to use java.util.TimeZone.useDaylightTime() method.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a TimeZone objects
    TimeZone tz1 = TimeZone.getTimeZone("CST");
    TimeZone tz2 = TimeZone.getTimeZone("IST");

    //checking if tz1 uses day light
    System.out.print("tz1 uses day light: ");
    System.out.println(tz1.useDaylightTime());

    //checking if tz2 uses day light
    System.out.print("tz2 uses day light: ");
    System.out.println(tz2.useDaylightTime());
  }
}

The output of the above code will be:

tz1 uses day light: true
tz2 uses day light: false

❮ Java.util - TimeZone