SimpleTimeZone setStartYear() method in Java

The setStartYear() method of SimpleTimeZone class is used to set the daylight saving time starting year.

Syntax:

public void setStartYear(int year)

Parameters: The function accepts a single parameter year which specifies the daylight saving starting year.



Return Value: The method has no return value.

Exception: The function does not throws any exception.

Program below demonstrates the above mentioned function:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// program to demonstrate the
// function SimpleTimeZone.setStartYear()
  
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(500, "US");
  
        // printing
        System.out.println("SimpleTimeZone: "
                           + obj);
  
        // setting start year
        obj.setStartYear(2000);
  
        System.out.println("\nStartYear "
                           + "set to 2000\n");
  
        // printing the final value
        System.out.println("SimpleTimeZone: "
                           + obj);
    }
}

chevron_right


Output:

SimpleTimeZone: java.util.SimpleTimeZone[
    id=US,
    offset=500,
    dstSavings=3600000,
    useDaylight=false,
    startYear=0,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]

StartYear set to 2000

SimpleTimeZone: java.util.SimpleTimeZone[
    id=US,
    offset=500,
    dstSavings=3600000,
    useDaylight=false,
    startYear=2000,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// program to demonstrate the
// function SimpleTimeZone.setStartYear()
  
import java.util.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(620, "US");
  
        // printing
        System.out.println("SimpleTimeZone: "
                           + obj);
  
        // setting start year
        obj.setStartYear(2018);
  
        System.out.println("\nStartYear "
                           + "set to 2018\n");
  
        // printing the final value
        System.out.println("SimpleTimeZone: "
                           + obj);
    }
}

chevron_right


Output:

SimpleTimeZone: java.util.SimpleTimeZone[
    id=US,
    offset=620,
    dstSavings=3600000,
    useDaylight=false,
    startYear=0,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]

StartYear set to 2018

SimpleTimeZone: java.util.SimpleTimeZone[
    id=US,
    offset=620,
    dstSavings=3600000,
    useDaylight=false,
    startYear=2018,
    startMode=0,
    startMonth=0,
    startDay=0,
    startDayOfWeek=0,
    startTime=0,
    startTimeMode=0,
    endMode=0,
    endMonth=0,
    endDay=0,
    endDayOfWeek=0,
    endTime=0,
    endTimeMode=0]


My Personal Notes arrow_drop_up

Contented with little yet wishing for more

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.