当前位置: 首页>>代码示例>>Java>>正文


Java ZoneOffset.ofHoursMinutesSeconds方法代码示例

本文整理汇总了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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TCKZoneRules.java

示例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());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TCKZoneOffset.java

示例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)},
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:75,代码来源:TestZoneOffsetParser.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKZoneOffset.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKZoneOffset.java


注:本文中的java.time.ZoneOffset.ofHoursMinutesSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。