java.util.SimpleTimeZone.setEndRule()


描述

所述setEndRule(int endMonth, int endDay, int endDayOfWeek, int endTime)方法用于设置夏令时结束规则。

声明

以下是java.util.SimpleTimeZone.setEndRule()方法的声明。

public void setEndRule(int endMonth,
                       int endDay,
                       int endDayOfWeek,
                       int endTime)

参数

endMonth - 夏令时结束月份。

endDay - 夏令时结束的月份中的某一天。

endTime - 本地挂钟时间的夏令时结束时间。

endDayOfWeek - 夏令时结束的星期几。

返回值

NA

异常

IllegalArgumentException - 如果endMonth,endDay,endDayOfWeek或endTime参数超出范围,则抛出此异常。

实例

以下示例显示了java.util.SimpleTimeZone.setEndRule()的用法

package com.tutorialspoint;

import java.util.*;

public class SimpleTimeZoneDemo {
   public static void main( String args[] ) {

      // create simple time zone object
      SimpleTimeZone stobj = new SimpleTimeZone(-28800000,
      "America/Los_Angeles", Calendar.AUGUST, 1,-Calendar.SUNDAY, 7200000,
      Calendar.DECEMBER, -1, Calendar.SUNDAY, 7200000, 3600000);

      // checking the initial value      
      System.out.println("Initial value : " + stobj);

      // setting end rule
      stobj.setEndRule( Calendar.MAY, 2, Calendar.TUESDAY, 3600000);

      // checking the new value      
      System.out.println("New 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]
New 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 = 2,endMonth = 4,
endDay = 2,endDayOfWeek = 3,endTime = 3600000,endTimeMode = 0]