mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for OneBusAway
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
b23cb757c4
commit
a989208cc6
@ -15,8 +15,6 @@ package org.openhab.binding.onebusaway.internal.handler;
|
|||||||
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
|
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -168,8 +166,7 @@ public class RouteHandler extends BaseThingHandler implements RouteDataListener
|
|||||||
private void publishChannel(ChannelUID channelUID, Calendar now, long lastUpdateTime,
|
private void publishChannel(ChannelUID channelUID, Calendar now, long lastUpdateTime,
|
||||||
List<ArrivalAndDeparture> arrivalAndDepartures) {
|
List<ArrivalAndDeparture> arrivalAndDepartures) {
|
||||||
if (channelUID.getId().equals(CHANNEL_ID_UPDATE)) {
|
if (channelUID.getId().equals(CHANNEL_ID_UPDATE)) {
|
||||||
updateState(channelUID, new DateTimeType(
|
updateState(channelUID, new DateTimeType(Instant.ofEpochMilli(lastUpdateTime)));
|
||||||
ZonedDateTime.ofInstant(Instant.ofEpochMilli(lastUpdateTime), ZoneId.systemDefault())));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +198,7 @@ public class RouteHandler extends BaseThingHandler implements RouteDataListener
|
|||||||
logger.debug("Not notifying {} because it is in the past.", channelUID.getId());
|
logger.debug("Not notifying {} because it is in the past.", channelUID.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
updateState(channelUID,
|
updateState(channelUID, new DateTimeType(time.toInstant()));
|
||||||
new DateTimeType(ZonedDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault())));
|
|
||||||
|
|
||||||
// Update properties only when we update arrival information. This is not perfect.
|
// Update properties only when we update arrival information. This is not perfect.
|
||||||
if (channelUID.getId().equals(CHANNEL_ID_ARRIVAL)) {
|
if (channelUID.getId().equals(CHANNEL_ID_ARRIVAL)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user