SimpleTimeZone類的setStartYear()方法用於設置夏令時開始的年份。
用法:
public void setStartYear(int year)
參數:該函數接受單個參數year,該參數指定夏令時的開始年份。
返回值:該方法沒有返回值。
異常:該函數不會引發任何異常。
下麵的程序演示了上述函數:
示例1:
// 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);
}
}
輸出:
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]
示例2:
// 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);
}
}
輸出:
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]
相關用法
- Java SimpleTimeZone useDaylightTime()用法及代碼示例
- Java SimpleTimeZone hasSameRules()用法及代碼示例
- Java SimpleTimeZone equals()用法及代碼示例
- Java SimpleTimeZone getOffset()用法及代碼示例
- Java SimpleTimeZone hashCode()用法及代碼示例
- Java SimpleTimeZone getDSTSavings()用法及代碼示例
- Java SimpleTimeZone getRawOffset()用法及代碼示例
- Java SimpleTimeZone clone()用法及代碼示例
- Java SimpleTimeZone setRawOffset()用法及代碼示例
- Java SimpleTimeZone setDSTSavings()用法及代碼示例
- Java SimpleTimeZone inDaylightTime()用法及代碼示例
- Java SimpleTimeZone toString()用法及代碼示例
- Java SimpleTimeZone setEndRule(int, int, int)用法及代碼示例
- Java SimpleTimeZone setStartRule(int, int, int)用法及代碼示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代碼示例
注:本文由純淨天空篩選整理自Twinkl Bajaj大神的英文原創作品 SimpleTimeZone setStartYear() method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。