Java SimpleTimeZone.setDSTSavings(int millisSavedDuringDST) method example

 Posted On  | Pooja Lakkihal 

In this tutorial, You will learn how to set the DST saving time using Java SimpleTimeZone.setDSTSavings(int millisSavedDuringDST) method. It sets the amount of time in milliseconds that the clock is advanced during daylight saving time.

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

syntax

public void setDSTSavings(int millisSavedDuringDST)

Parameters

millisSavedDuringDST - the number of milliseconds the time is advanced with respect to standard time when the daylight saving time rules are in effect.

Java SimpleTimeZone setDSTSavings(int millisSavedDuringDST) 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.0255 seconds.