Sunday, February 8, 2026
HomeLanguagesJavaTimeZone useDaylightTime() method in Java with Examples

TimeZone useDaylightTime() method in Java with Examples

The useDaylightTime() method of TimeZone class is used perform a query on this time zone to know whether it uses the daylight saving time.

Syntax:

public abstract boolean useDaylightTime()

Parameters: The method does not accept any parameters.

Return Value: The method returns either of the two boolean values:

  • ‘true’ if this time zone uses daylight saving time
  • ‘false’ if this time zone does not use daylight saving time

Below program demonstrates the above-mentioned function:
Example 1:




// Program to demonstrate the
// useDaylightTime()
  
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create TimeZone object
        TimeZone obj
            = TimeZone.getTimeZone("Europe/Rome");
  
        // Checking day light time
        // and displaying the result
        System.out.println("Day light time is = "
                           + obj.useDaylightTime());
    }
}


Output:

Day light time is = true

Example 2:




// Program to demonstrate the
// useDaylightTime()
  
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create TimeZone object
        TimeZone obj
            = TimeZone.getTimeZone("Pacific/Pago_Pago");
  
        // checking day light time
        // and printing the result
        System.out.println("Day light time is = "
                           + obj.useDaylightTime());
    }
}


Output:

Day light time is = false

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#useDaylightTime()

RELATED ARTICLES

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12084 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7241 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS