Java SimpleTimeZone.inDaylightTime(Date date) method example

 Posted On  | Pooja Lakkihal 

In this tutorial, You will learn how to check if the date is in daylight saving time or not . Java SimpleTimeZone.inDaylightTime(Date date) method returns true if daylight saving time is in effective at the given date.

Queries if the given date is in daylight saving time.

syntax

public boolean inDaylightTime(Date date)

Parameters

date - the given Date.

Returns

true if daylight saving time is in effective at the given date; false otherwise.

Java SimpleTimeZone inDaylightTime(Date date) example

  • new SimpleTimeZone(100, "INDIA"); It will construct a SimpleTimeZone with the given base time zone.
  • new Date(2018, 05, 03); It will create a new date object.
  • simpleTimeZone.inDaylightTime(date); It will check if the given date is in daylight saving time.
package com.technicalkeeda;

import java.util.Date;
import java.util.SimpleTimeZone;

public class App {

    public static void main(String[] args) {

        SimpleTimeZone simpleTimeZone = new SimpleTimeZone(100, "INDIA");

        Date date = new Date(2018, 05, 03);

        boolean daylight = simpleTimeZone.inDaylightTime(date);

        System.out.println("Is this date in day light ? " + daylight);
    }
}

output

Is this date in day light ? false


© technicalkeeda.com 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0320 seconds.