Java 中 SimpleTimeZone setStartRule(int,int,int)方法,示例
语法:
public void setStartRule(int *startofMonth*,
int *startofDay*,
int *startofTime*)
参数:该方法取三个参数:
- 起始月:整数类型,指夏令时的起始月。
- 开始日期:整数类型,指夏令时的开始日期。
- 开始时间:整数类型,指夏令时的开始时间。
返回值:该方法不返回值。
以下程序说明了 setStartRule()方法在 Java 中的使用: 示例 1:
// Java code to demonstrate
// setStartRule() 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 StartRule
simtimeobj.setStartRule(Calendar.APRIL,
28, 3600000);
// Displaying the New value
System.out.println(
"New value: " + simtimeobj);
}
}
Output:
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=1, startMonth=3, startDay=28, startDayOfWeek=0,
startTime=3600000, startTimeMode=0, endMode=0, endMonth=0, endDay=0, endDayOfWeek=0,
endTime=0, endTimeMode=0]
例 2:
// Java code to demonstrate
// setStartRule() 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 StartRule
simtimeobj.setStartRule(Calendar.JANUARY,
15, 3600000);
// Displaying the New value
System.out.println(
"New value: " + simtimeobj);
}
}
Output:
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=1, startMonth=0, startDay=15, startDayOfWeek=0,
startTime=3600000, startTimeMode=0, endMode=0, endMonth=0, endDay=0, endDayOfWeek=0,
endTime=0, endTimeMode=0]
版权属于:月萌API www.moonapi.com,转载请注明出处