本文整理汇总了Java中java.util.SimpleTimeZone.getRawOffset方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleTimeZone.getRawOffset方法的具体用法?Java SimpleTimeZone.getRawOffset怎么用?Java SimpleTimeZone.getRawOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SimpleTimeZone
的用法示例。
在下文中一共展示了SimpleTimeZone.getRawOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Test4278609
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
public void Test4278609() {
SimpleTimeZone tz = new SimpleTimeZone(0, "MyTimeZone",
/* DST start day: August, 1, 0:00 */
Calendar.AUGUST, 1, 0, 0,
/* DST end day: January, 1, 0:00 (wall-clock)*/
Calendar.JANUARY, 1, 0, 0,
60 * 60 * 1000);
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
// setting a date using GMT zone just after the end rule of tz zone
cal.clear();
cal.set(Calendar.ERA, GregorianCalendar.AD);
cal.set(1998, Calendar.DECEMBER, 31, 23, 01, 00);
Date date = cal.getTime();
int millis = cal.get(Calendar.HOUR_OF_DAY) * 3600000
+ cal.get(Calendar.MINUTE) * 60000
+ cal.get(Calendar.SECOND) * 1000
+ cal.get(Calendar.MILLISECOND);
/* we must use standard local time */
millis += tz.getRawOffset();
int offset = tz.getOffset(cal.get(Calendar.ERA),
cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH),
cal.get(Calendar.DATE),
cal.get(Calendar.DAY_OF_WEEK),
millis);
if (offset != 0) {
SimpleDateFormat format = new SimpleDateFormat("dd MMM HH:mm:ss zzz",
Locale.US);
format.setTimeZone(tz);
errln("Wrong DST transition: " + tz
+ "\na date just after DST = " + format.format(date)
+ "\ngetOffset = " + offset);
}
}
示例2: test_setRawOffsetI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setRawOffset(int)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setRawOffset",
args = {int.class}
)
public void test_setRawOffsetI() {
// Test for method void java.util.SimpleTimeZone.setRawOffset(int)
st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
int off = st1.getRawOffset();
st1.setRawOffset(1000);
boolean val = st1.getRawOffset() == 1000;
st1.setRawOffset(off);
assertTrue("Incorrect offset set", val);
}
示例3: test_setRawOffsetI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setRawOffset(int)
*/
public void test_setRawOffsetI() {
// Test for method void java.util.SimpleTimeZone.setRawOffset(int)
st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
int off = st1.getRawOffset();
st1.setRawOffset(1000);
boolean val = st1.getRawOffset() == 1000;
st1.setRawOffset(off);
assertTrue("Incorrect offset set", val);
}