本文整理汇总了Java中java.time.ZoneOffset.ofHoursMinutesSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneOffset.ofHoursMinutesSeconds方法的具体用法?Java ZoneOffset.ofHoursMinutesSeconds怎么用?Java ZoneOffset.ofHoursMinutesSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZoneOffset
的用法示例。
在下文中一共展示了ZoneOffset.ofHoursMinutesSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_equals
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_equals() {
ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
ZoneOffset offset2b = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
assertEquals(offset1.equals(offset2), false);
assertEquals(offset2.equals(offset1), false);
assertEquals(offset1.equals(offset1), true);
assertEquals(offset2.equals(offset2), true);
assertEquals(offset2.equals(offset2b), true);
assertEquals(offset1.hashCode() == offset1.hashCode(), true);
assertEquals(offset2.hashCode() == offset2.hashCode(), true);
assertEquals(offset2.hashCode() == offset2b.hashCode(), true);
}
示例2: test_getRules
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_getRules() {
ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
assertEquals(offset.getRules().isFixedOffset(), true);
assertEquals(offset.getRules().getOffset((Instant) null), offset);
assertEquals(offset.getRules().getDaylightSavings((Instant) null), Duration.ZERO);
assertEquals(offset.getRules().getStandardOffset((Instant) null), offset);
assertEquals(offset.getRules().nextTransition((Instant) null), null);
assertEquals(offset.getRules().previousTransition((Instant) null), null);
assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, offset), true);
assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, ZoneOffset.UTC), false);
assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, null), false);
assertEquals(offset.getRules().getOffset((LocalDateTime) null), offset);
assertEquals(offset.getRules().getValidOffsets((LocalDateTime) null), Arrays.asList(offset));
assertEquals(offset.getRules().getTransition((LocalDateTime) null), null);
assertEquals(offset.getRules().getTransitions().size(), 0);
assertEquals(offset.getRules().getTransitionRules().size(), 0);
}
示例3: test_Paris_preTimeZones
import java.time.ZoneOffset; //导入方法依赖的package包/类
public void test_Paris_preTimeZones() {
ZoneRules test = europeParis();
ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
Instant instant = old.toInstant();
ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21);
assertEquals(test.getOffset(instant), offset);
checkOffset(test, old.toLocalDateTime(), offset, 1);
assertEquals(test.getStandardOffset(instant), offset);
assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
assertEquals(test.isDaylightSavings(instant), false);
}
示例4: test_adjustInto_OffsetDateTime
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_adjustInto_OffsetDateTime() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
for (int i=-18; i<=18; i++) {
OffsetDateTime offsetDateTime_target = OffsetDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneOffset.ofHours(i));
OffsetDateTime offsetDateTime_result = (OffsetDateTime)base.adjustInto(offsetDateTime_target);
assertEquals(base, offsetDateTime_result.getOffset());
//Do not change offset of ZonedDateTime after adjustInto()
ZonedDateTime zonedDateTime_target = offsetDateTime_target.toZonedDateTime();
ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());
}
}
示例5: test_compareTo
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_compareTo() {
ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
assertTrue(offset1.compareTo(offset2) > 0);
assertTrue(offset2.compareTo(offset1) < 0);
assertTrue(offset1.compareTo(offset1) == 0);
assertTrue(offset2.compareTo(offset2) == 0);
}
示例6: provider_offsets
import java.time.ZoneOffset; //导入方法依赖的package包/类
@DataProvider(name="offsets")
Object[][] provider_offsets() {
return new Object[][] {
{"+HH", "+00", ZoneOffset.UTC},
{"+HH", "-00", ZoneOffset.UTC},
{"+HH", "+01", ZoneOffset.ofHours(1)},
{"+HH", "-01", ZoneOffset.ofHours(-1)},
{"+HHMM", "+0000", ZoneOffset.UTC},
{"+HHMM", "-0000", ZoneOffset.UTC},
{"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)},
{"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)},
{"+HH:MM", "+00:00", ZoneOffset.UTC},
{"+HH:MM", "-00:00", ZoneOffset.UTC},
{"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)},
{"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)},
{"+HHMMss", "+0000", ZoneOffset.UTC},
{"+HHMMss", "-0000", ZoneOffset.UTC},
{"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)},
{"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)},
{"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)},
{"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)},
{"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)},
{"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)},
{"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)},
{"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)},
{"+HHMMss", "+000000", ZoneOffset.UTC},
{"+HHMMss", "-000000", ZoneOffset.UTC},
{"+HHMMss", "+010000", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)},
{"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)},
{"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)},
{"+HHMMss", "+020000", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)},
{"+HHMMss", "+180000", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)},
{"+HHMMss", "-010000", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)},
{"+HHMMss", "-020000", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)},
{"+HHMMss", "-180000", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)},
{"+HH:MM:ss", "+00:00", ZoneOffset.UTC},
{"+HH:MM:ss", "-00:00", ZoneOffset.UTC},
{"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)},
{"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)},
{"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)},
{"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)},
{"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)},
{"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)},
{"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)},
{"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)},
{"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)},
{"+HH:MM:ss", "+00:00:00", ZoneOffset.UTC},
{"+HH:MM:ss", "-00:00:00", ZoneOffset.UTC},
{"+HH:MM:ss", "+01:00:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)},
{"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)},
{"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)},
{"+HH:MM:ss", "+02:00:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)},
{"+HH:MM:ss", "+18:00:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)},
{"+HH:MM:ss", "-01:00:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)},
{"+HH:MM:ss", "-02:00:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)},
{"+HH:MM:ss", "-18:00:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)},
{"+HHMMSS", "+000000", ZoneOffset.UTC},
{"+HHMMSS", "-000000", ZoneOffset.UTC},
{"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)},
{"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)},
{"+HH:MM:SS", "+00:00:00", ZoneOffset.UTC},
{"+HH:MM:SS", "-00:00:00", ZoneOffset.UTC},
{"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)},
{"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)},
};
}
示例7: test_factory_int_hours_minutes_seconds_plusHoursMinusMinutes
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_plusHoursMinusMinutes() {
ZoneOffset.ofHoursMinutesSeconds(1, -1, 0);
}
示例8: test_factory_int_hours_minutes_seconds_plusHoursMinusSeconds
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_plusHoursMinusSeconds() {
ZoneOffset.ofHoursMinutesSeconds(1, 0, -1);
}
示例9: test_factory_int_hours_minutes_seconds_minusHoursPlusMinutes
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_minusHoursPlusMinutes() {
ZoneOffset.ofHoursMinutesSeconds(-1, 1, 0);
}
示例10: test_factory_int_hours_minutes_seconds_zeroHoursPlusMinutesMinusSeconds
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_zeroHoursPlusMinutesMinusSeconds() {
ZoneOffset.ofHoursMinutesSeconds(0, 1, -1);
}
示例11: samples
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Override
protected List<TemporalAccessor> samples() {
TemporalAccessor[] array = {ZoneOffset.ofHours(1), ZoneOffset.ofHoursMinutesSeconds(-5, -6, -30) };
return Arrays.asList(array);
}
示例12: test_factory_int_hours_minutes_seconds_minutesTooLarge
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_minutesTooLarge() {
ZoneOffset.ofHoursMinutesSeconds(0, 60, 0);
}
示例13: test_factory_int_hours_minutes_seconds_minusHoursPlusSeconds
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_minusHoursPlusSeconds() {
ZoneOffset.ofHoursMinutesSeconds(-1, 0, 1);
}
示例14: test_factory_int_hours_minutes_seconds_secondsTooLarge
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_secondsTooLarge() {
ZoneOffset.ofHoursMinutesSeconds(0, 0, 60);
}
示例15: test_factory_int_hours_minutes_seconds_secondsMinValue
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_hours_minutes_seconds_secondsMinValue() {
ZoneOffset.ofHoursMinutesSeconds(0, 0, Integer.MIN_VALUE);
}