List of usage examples for java.time ZonedDateTime getOffset
@Override
public ZoneOffset getOffset()
From source file:org.openhab.binding.ntp.test.NtpOSGiTest.java
@Test public void testDateTimeChannelDefaultTimeZoneUpdate() { ZonedDateTime zoned = ZonedDateTime.now(); ZoneOffset expectedTimeZone = zoned.getOffset(); Configuration configuration = new Configuration(); // Initialize with configuration with no time zone property set. initialize(configuration, NtpBindingConstants.CHANNEL_DATE_TIME, ACCEPTED_ITEM_TYPE_DATE_TIME, null, null); String testItemState = getItemState(ACCEPTED_ITEM_TYPE_DATE_TIME).toString(); assertFormat(testItemState, DateTimeType.DATE_PATTERN_WITH_TZ_AND_MS); ZoneOffset timeZoneFromItemRegistry = new DateTimeType(testItemState).getZonedDateTime().getOffset(); assertEquals(expectedTimeZone, timeZoneFromItemRegistry); }
From source file:org.openhab.binding.ntp.test.NtpOSGiTest.java
@Test @Ignore("https://github.com/eclipse/smarthome/issues/5224") public void testDateTimeChannelCalendarDefaultTimeZoneUpdate() { Configuration configuration = new Configuration(); // Initialize with configuration with no time zone property set. initialize(configuration, NtpBindingConstants.CHANNEL_DATE_TIME, ACCEPTED_ITEM_TYPE_DATE_TIME, null, null); ZonedDateTime timeZoneIdFromItemRegistry = ((DateTimeType) getItemState(ACCEPTED_ITEM_TYPE_DATE_TIME)) .getZonedDateTime();/*from w w w . j av a2 s . c o m*/ ZoneOffset expectedOffset = ZoneId.systemDefault().getRules() .getOffset(timeZoneIdFromItemRegistry.toInstant()); assertEquals(expectedOffset, timeZoneIdFromItemRegistry.getOffset()); }