Open In App

SimpleTimeZone useDaylightTime() method in Java

Improve
Improve
Like Article
Like
Save
Share
Report

The useDaylightTime() method of SimpleTimeZone class is used as a query if this time zone uses daylight saving time.

Syntax:

public boolean useDaylightTime()

Parameters: The function does not accepts any parameter.

Return Value: The method gives either of the two return value:

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

Exception: The function does not throws any exception.

Program below demonstrates the above mentioned function:




// program to demonstrate the
// function java.util.SimpleTimeZone.useDaylightTime()
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(700, "US");
  
        // checking day light time
        // and printing the result
        System.out.println("Day light time is = "
                           + obj.useDaylightTime());
    }
}


Output:

Day light time is = false




// program to demonstrate the
// function java.util.SimpleTimeZone.useDaylightTime()
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(820, "India");
  
        // checking day light time
        // and printing the result
        System.out.println("Day light time is = "
                           + obj.useDaylightTime());
    }
}


Output:

Day light time is = false


Last Updated : 03 Jan, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads