Java TimeZone - observesDaylightTime() Method
The java.util.TimeZone.observesDaylightTime() method returns true if this TimeZone is currently in Daylight Saving Time, or if a transition from Standard Time to Daylight Saving Time occurs at any future time.
Syntax
public boolean observesDaylightTime()
Parameters
No parameter is required.
Return Value
Returns true if this TimeZone is currently in Daylight Saving Time, or if a transition from Standard Time to Daylight Saving Time occurs at any future time; false otherwise.
Exception
NA
Example:
The example below explains how to use java.util.TimeZone.observesDaylightTime() 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"); //printing the value of day light for tz1 System.out.print("tz1 is in day light: "); System.out.println(tz1.observesDaylightTime()); //printing the value of day light for tz2 System.out.print("tz2 is in day light: "); System.out.println(tz2.observesDaylightTime()); } }
The output of the above code will be:
tz1 is in day light: true tz2 is in day light: false
❮ Java.util - TimeZone