Java SimpleTimeZone setStartRule()方法与示例
SimpleTimeZone類setStartRule()方法 (SimpleTimeZone Class setStartRule() method)
Syntax:
句法:
public void setStartRule(int st_mm, int st_dd, int st_time);public void setStartRule(int st_mm, int st_dd, int st_dow, int st_time);public void setStartRule(int st_mm, int st_dd,int st_dow, int st_time, boolean status);setStartRule() method is available in java.util package.
setStartRule()方法在java.util包中可用。
setStartRule(int st_mm, int st_dd, int st_time) method is used to set the start rule of DST(Daylight Savings Time) to the given fixed date (dd) in a month.
setStartRule(int st_mm,int st_dd,int st_time)方法用于將DST(夏令時)的開始規則設置為一個月中的給定固定日期(dd)。
setStartRule(int st_mm, int st_dd,int st_dow, int st_time) method is used to set the start rule of DST(Daylight Savings Time).
setStartRule(int st_mm,int st_dd,int st_dow,int st_time)方法用于設置DST(夏令時)的開始規則。
setStartRule(int st_mm, int st_dd, int st_dow, int st_time, boolean status) method is used to set the start rule of DST(Daylight Savings Time) to the earlier weekday (dow) or after the given date (dd) in a month.
setStartRule(int st_mm,int st_dd,int st_dow,int st_time,boolean status)方法用于將DST(夏時制)的開始規則設置為較早的工作日(dow)或一個月中給定的日期(dd)之后。
These methods may throw an exception at the time of setting start rule.
這些方法在設置開始規則時可能會引發異常。
IllegalArgumentException: This exception may throw when any one of the parameters is not in a range.
IllegalArgumentException :當任何一個參數不在范圍內時,可能引發此異常。
These are non-static methods and it is accessible with the class object only and if we try to access these methods with the class name then we will get an error.
這些是非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問這些方法,則會收到錯誤消息。
Parameter(s):
參數:
In the first case, setStartRule(int st_mm, int st_dd, int st_time)
在第一種情況下, setStartRule(int st_mm,int st_dd,int st_time)
- int st_mm – represents the DST starting month.
- int st_mm –表示夏令時開始的月份。
- int st_dd – represents the DST starting day of month.
- int st_dd –表示夏令時開始的月份。
- int st_time – represents the DST starting time.
- int st_time –表示DST的開始時間。
In the second case, setStartRule(int st_mm, int st_dd, int st_dow, int st_time),
在第二種情況下, setStartRule(int st_mm,int st_dd,int st_dow,int st_time) ,
- int st_mm – represents the DST starting month.
- int st_mm –表示夏令時開始的月份。
- int st_dd – represents the DST starting day of month.
- int st_dd –表示夏令時開始的月份。
- int st_dow – represents the DST starting day of week.
- int st_dow –表示夏令時開始的星期幾。
- int st_time – represents the DST starting time.
- int st_time –表示DST的開始時間。
In the second case, setStartRule(int st_mm, int st_dd,int st_dow, int st_time, boolean status),
在第二種情況下, setStartRule(int st_mm,int st_dd,int st_dow,int st_time,布爾狀態) ,
- int st_mm – represents the DST starting month.
- int st_mm –表示夏令時開始的月份。
- int st_dd – represents the DST starting day of month.
- int st_dd –表示夏令時開始的月份。
- int st_dow – represents the DST starting day of week.
- int st_dow –表示夏令時開始的星期幾。
- int st_time – represents the DST starting time.
- int st_time –表示DST的開始時間。
- boolean status – sets to true then this rule selects first st_dow on or after st_dd otherwise this rule selects last st_dow on or before st_dd.
- 布爾狀態 –設置為true,然后此規則在st_dd或之后選擇第一個st_dow,否則,在st_dd或之前選擇最后一個st_dow。
Return value:
返回值:
In all cases, the return type of the method is void – It returns nothing.
在所有情況下,該方法的返回類型均為空 –它不返回任何內容。
Example:
例:
// Java program to demonstrate the example // of setStartRule() method of SimpleTimeZoneimport java.util.*;public class SetStartRuleOfSimpleTimeZone {public static void main(String args[]) {// Instantiates SimpleTimeZone objectSimpleTimeZone s_tz1 = new SimpleTimeZone(360, "FRANCE");SimpleTimeZone s_tz2 = new SimpleTimeZone(760, "JAPAN");SimpleTimeZone s_tz3 = new SimpleTimeZone(39800000, "US",Calendar.APRIL, 6, -Calendar.MONDAY, 7200000, Calendar.OCTOBER, -1,Calendar.MONDAY, 7200000, 3600000);// By using setStartRule(yy,mm,dd) method is used to// set the DST start rule to a constant dates_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY, 3800000);// By using setStartRule(yy,mm,dow,dd) method is used to// set the DST start rule to a weekday before// or after the given dates_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY, 2, 3800000, false);// By using setStartRule(yy,mm,dow,dd,boolean) method is used to// set the DST start rule s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY, 2, 3800000);// Display SimpleTimeZoneSystem.out.print("s_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000): ");System.out.println(s_tz1);System.out.print("s_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000,false): ");System.out.println(s_tz1);System.out.print("s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY,2,3800000): ");System.out.println(s_tz1);} }Output
輸出量
s_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0] s_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000,false): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0] s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY,2,3800000): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]翻譯自: https://www.includehelp.com/java/simpletimezone-setstartrule-method-with-example.aspx
總結
以上是生活随笔為你收集整理的Java SimpleTimeZone setStartRule()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python中acosh_带有Pytho
- 下一篇: 网页设置页数/总页数_图书分配问题(分配