The setEndRule(int endofMonth, int endofDay, int endofTime) method of SimpleTimeZone class in Java is used to set a particular rule of the day-light saving time to a fixed date within a given month.
Syntax:
public void setEndRule(int endofMonth,
int endofDay,
int endofTime)
Parameters: The method takes three parameters:
- endofMonth: This is of Integer type and refers to the ending month of the daylight saving time.
- endofDay: This is of Integer type and refers to the ending day of the daylight saving time.
- endofTime: This is of Integer type and refers to the ending time of the daylight saving time.
Return Value: The method does not return any value.
Below programs illustrate the use of setEndRule() Method in Java:
Example 1:
// Java code to demonstrate // setEndRule() method import java.util.*; public class SimpleTimeZone_Demo { public static void main(String[] args) { // Creating SimpleTimeZone object SimpleTimeZone simtimeobj = new SimpleTimeZone(100, "GMT"); // Displaying the Initial value System.out.println( "Initial value: " + simtimeobj); // Setting an EnDRule simtimeobj.setEndRule(Calendar.APRIL, 28, 3600000); // Displaying the New value System.out.println( "New value: " + simtimeobj); } } |
Initial value: java.util.SimpleTimeZone[id=GMT, offset=100, 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] New value: java.util.SimpleTimeZone[id=GMT, offset=100, dstSavings=3600000, useDaylight=false, startYear=0, startMode=0, startMonth=0, startDay=0, startDayOfWeek=0, startTime=0, startTimeMode=0, endMode=1, endMonth=3, endDay=28, endDayOfWeek=0, endTime=3600000, endTimeMode=0]
Example 2:
// Java code to demonstrate // setEndRule() method import java.util.*; public class SimpleTimeZone_Demo { public static void main(String[] args) { // Creating SimpleTimeZone object SimpleTimeZone simtimeobj = new SimpleTimeZone(120, "GMT"); // Displaying the Initial value System.out.println( "Initial value: " + simtimeobj); // Setting an EnDRule simtimeobj.setEndRule(Calendar.JANUARY, 15, 3600000); // Displaying the New value System.out.println( "New value: " + simtimeobj); } } |
Initial value: java.util.SimpleTimeZone[id=GMT, offset=120, 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] New value: java.util.SimpleTimeZone[id=GMT, offset=120, dstSavings=3600000, useDaylight=false, startYear=0, startMode=0, startMonth=0, startDay=0, startDayOfWeek=0, startTime=0, startTimeMode=0, endMode=1, endMonth=0, endDay=15, endDayOfWeek=0, endTime=3600000, endTimeMode=0]
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/SimpleTimeZone.html#setEndRule(int,int,int)
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- SimpleTimeZone setStartRule(int, int, int) method in Java with Examples
- TimeZone getOffset(int, int, int, int, int, int) Method in Java with Examples
- SimpleTimeZone hashCode() method in Java with Examples
- SimpleTimeZone getRawOffset() method in Java with Examples
- SimpleTimeZone clone() method in Java with Examples
- SimpleTimeZone getDSTSavings() method in Java with Examples
- SimpleTimeZone getOffset() method in Java with Examples
- SimpleTimeZone equals() method in Java with Examples
- SimpleTimeZone hasSameRules() method in Java with Examples
- SimpleTimeZone setRawOffset() method in Java with Examples
- SimpleTimeZone toString() method in Java with Examples
- SimpleTimeZone setDSTSavings() method in Java with Examples
- SimpleTimeZone inDaylightTime() method in Java with Examples
- SimpleTimeZone setStartYear() method in Java
- SimpleTimeZone useDaylightTime() method in Java
- ZoneOffset ofHoursMinutesSeconds(int, int, int) method in Java with Examples
- HijrahDate of(int, int, int) method in Java with Example
- IsoChronology date(int, int, int) method in Java with Example
- JapaneseChronology date(int, int, int) method in Java with Example
- JapaneseDate of(int, int, int) method in Java with Example
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.

