TimeZone useDaylightTime() method in Java with Examples
Last Updated :
19 Jul, 2019
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:
import java.util.*;
public class GFG {
public static void main(String[] args)
{
TimeZone obj
= TimeZone.getTimeZone( "Europe/Rome" );
System.out.println( "Day light time is = "
+ obj.useDaylightTime());
}
}
|
Output:
Day light time is = true
Example 2:
import java.util.*;
public class GFG {
public static void main(String[] args)
{
TimeZone obj
= TimeZone.getTimeZone( "Pacific/Pago_Pago" );
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()
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...