java.util.SimpleTimeZone.setStartRule() java.util.SimpleTimeZone.setStartRule() java.util.SimpleTimeZone.setStartRule() 描述 所述setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime)方法用于设置夏令时开始规则。 声明 以下是java.util.SimpleTimeZone.setStartRule()方法的声明。 public void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime) 参数 startMonth - 开始月份的夏令时。 startDay - 夏令时开始的月份中的某一天。 startDayOfWeek - 从星期几开始的夏令时。 startTime - 本地挂钟时间的夏令时开始时间。 返回值 NA 异常 IllegalArgumentException - 如果startMonth,startDay,startDayOfWeek或startTime参数超出范围,则抛出此异常。 实例 以下示例显示了java.util.SimpleTimeZone.setStartRule()的用法 package com.tutorialspoint; import java.util.*; public class SimpleTimeZoneDemo { public static void main( String args[] ) { // create simple time zone object SimpleTimeZone stobj = new SimpleTimeZone(820,"GMT"); // checking initial value System.out.println("Initial value: " + stobj); // setting start rule stobj.setStartRule( Calendar.MAY, 2,2, 3600000); // checking the new value System.out.println("Final value : " + stobj); } } 让我们编译并运行上面的程序,这将产生以下结果。 Initial value: java.util.SimpleTimeZone[id = GMT,offset = 820,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] Final value : java.util.SimpleTimeZone[id = GMT,offset = 820, dstSavings = 3600000,useDaylight = false,startYear = 0,startMode = 2, startMonth = 4,startDay = 2,startDayOfWeek = 2,startTime = 3600000, startTimeMode = 0,endMode = 0,endMonth = 0,endDay = 0,endDayOfWeek = 0, endTime = 0,endTimeMode = 0] java.util.SimpleTimeZone.setStartRule() java.util.SimpleTimeZone.setStartRule()