Java SimpleTimeZone.getDSTSavings() method example

 Posted On  | Pooja Lakkihal 

In this tutorial, You will learn how to get the DST saving time using Java SimpleTimeZone.getDSTSavings() method. It will returns the amount of time in milliseconds that the clock is advanced during daylight saving time.

Returns the amount of time in milliseconds that the clock is advanced during daylight saving time.

syntax

public int getDSTSavings()

Returns

The number of milliseconds the time is advanced with respect to standard time when the daylight saving rules are in effect, or 0 (zero) if this time zone doesn't observe daylight saving time.

Java SimpleTimeZone getDSTSavings() example

  • Create a SimpleTimeZone object with the given base time zone.
  • simpleTimeZone.setDSTSavings(1700000); It will set the DST saving time.
  • simpleTimeZone.getDSTSavings(); It returns the DST saving time.
package com.technicalkeeda;

import java.util.Calendar;
import java.util.SimpleTimeZone;

public class App {

    public static void main(String[] args) {

        SimpleTimeZone simpleTimeZone = new SimpleTimeZone(7200000, "India", Calendar.MAY, 1, -Calendar.SUNDAY, 7200000,
            Calendar.OCTOBER, -1, Calendar.MONDAY, 1200000, 3600000);

        System.out.println("Before setDSTSavings value :- " + simpleTimeZone.getDSTSavings());

        simpleTimeZone.setDSTSavings(1700000);

        System.out.println("Ater setDSTSavings value :- " + simpleTimeZone.getDSTSavings());
    }
}

output

Before setDSTSavings value :- 3600000

Ater setDSTSavings value :- 1700000


© technicalkeeda.com 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0447 seconds.