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()); } } |
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()); } } |
Day light time is = false
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#useDaylightTime()
Recommended Posts:
- TimeZone hasSameRules() Method in Java with Examples
- TimeZone setDefault() Method in Java with Examples
- TimeZone getRawOffset() Method in Java with Examples
- TimeZone getAvailableIDs() Method in Java with Examples
- TimeZone getID() Method in Java with Examples
- TimeZone getOffset() Method in Java with Examples
- TimeZone getDSTSavings() Method in Java with Examples
- TimeZone getDisplayName() Method in Java with Examples
- TimeZone getTimeZone() Method in Java with Examples
- TimeZone getDefault() Method in Java with Examples
- TimeZone getOffset(int, int, int, int, int, int) Method in Java with Examples
- TimeZone setID() Method in Java with Examples
- TimeZone setRawOffset() Method in Java with Examples
- TimeZone clone() Method in Java with Examples
- TimeZone observesDaylightTime() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Shivam_k



