@Override public State calculate(Set<Item> items) { if (items != null && items.size() > 0) { ZonedDateTime max = null; for (Item item : items) { DateTimeType itemState = item.getStateAs(DateTimeType.class); if (itemState != null) { if (max == null || max.isAfter(itemState.getZonedDateTime())) { max = itemState.getZonedDateTime(); } } } if (max != null) { return new DateTimeType(max); } } return UnDefType.UNDEF; }
public DateTimeType(String zonedValue) { ZonedDateTime date = null; try { // direct parsing (date and time) try { date = parse(zonedValue); } catch (DateTimeParseException fullDtException) { // time only try { date = parse("1970-01-01T" + zonedValue); } catch (DateTimeParseException timeOnlyException) { // date only if (zonedValue.length() == 10) { date = parse(zonedValue + "T00:00:00"); } else { date = parse(zonedValue.substring(0, 10) + "T00:00:00" + zonedValue.substring(10)); } } } } catch (DateTimeParseException invalidFormatException) { throw new IllegalArgumentException(zonedValue + " is not in a valid format.", invalidFormatException); } zonedDateTime = date; }
@Override public String toString() { return toFullString(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getZonedDateTime() == null) ? 0 : getZonedDateTime().hashCode()); return result; }
public static DateTimeType valueOf(String value) { return new DateTimeType(value); }
@Override protected Instant convert(DateTimeType value) { if (value == null) { return null; } return value.getCalendar().toInstant(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getZonedDateTime() == null) ? 0 : getZonedDateTime().hashCode()); return result; }
public static DateTimeType valueOf(String value) { return new DateTimeType(value); }
@Override public State calculate(Set<Item> items) { if (items != null && items.size() > 0) { ZonedDateTime max = null; for (Item item : items) { DateTimeType itemState = item.getStateAs(DateTimeType.class); if (itemState != null) { if (max == null || max.isBefore(itemState.getZonedDateTime())) { max = itemState.getZonedDateTime(); } } } if (max != null) { return new DateTimeType(max); } } return UnDefType.UNDEF; }
ZonedDateTime val = ((DateTimeType) state).getZonedDateTime(); ZonedDateTime now = ZonedDateTime.now(); long secsDif = ChronoUnit.SECONDS.between(now, val);
@Override protected DateTimeType convert(Instant value) { if (value == null) { return null; } Calendar calendar = GregorianCalendar.from(ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())); return new DateTimeType(calendar); }
@Override public String toString() { return toFullString(); }
public DateTimeType(String zonedValue) { ZonedDateTime date = null; try { // direct parsing (date and time) try { date = parse(zonedValue); } catch (DateTimeParseException fullDtException) { // time only try { date = parse("1970-01-01T" + zonedValue); } catch (DateTimeParseException timeOnlyException) { // date only if (zonedValue.length() == 10) { date = parse(zonedValue + "T00:00:00"); } else { date = parse(zonedValue.substring(0, 10) + "T00:00:00" + zonedValue.substring(10)); } } } } catch (DateTimeParseException invalidFormatException) { throw new IllegalArgumentException(zonedValue + " is not in a valid format.", invalidFormatException); } zonedDateTime = date; }
private ZonedDateTime convertTime(String sTime) { DateTimeType dateTime = new DateTimeType(sTime); return dateTime.getZonedDateTime(); }
ZonedDateTime val = ((DateTimeType) state).getZonedDateTime(); ZonedDateTime now = ZonedDateTime.now(); long secsDif = ChronoUnit.SECONDS.between(val, now);
@Override public void lastUpdatedChanged(Instant lastActivity) { Calendar calendar = GregorianCalendar.from(ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())); updateState(BluetoothBindingConstants.CHANNEL_LAST_UPDATED, new DateTimeType(calendar)); }
@Override public State calculate(Set<Item> items) { if (items != null && items.size() > 0) { ZonedDateTime max = null; for (Item item : items) { DateTimeType itemState = item.getStateAs(DateTimeType.class); if (itemState != null) { if (max == null || max.isAfter(itemState.getZonedDateTime())) { max = itemState.getZonedDateTime(); } } } if (max != null) { return new DateTimeType(max); } } return UnDefType.UNDEF; }
} else if (typeClass.equals(DateTimeType.class)) { result = new org.openhab.core.library.types.DateTimeType( GregorianCalendar.from(((DateTimeType) type).getZonedDateTime())); } else if (typeClass.equals(PointType.class)) { result = new org.openhab.core.library.types.PointType(type.toString());
result = new PercentType(type.toString()); } else if (typeClass.equals(org.openhab.core.library.types.DateTimeType.class)) { result = new DateTimeType(cloneCalendar(type)); } else if (typeClass.equals(org.openhab.core.library.types.PointType.class)) { result = new PointType(type.toString());
@Override public State calculate(Set<Item> items) { if (items != null && items.size() > 0) { ZonedDateTime max = null; for (Item item : items) { DateTimeType itemState = item.getStateAs(DateTimeType.class); if (itemState != null) { if (max == null || max.isBefore(itemState.getZonedDateTime())) { max = itemState.getZonedDateTime(); } } } if (max != null) { return new DateTimeType(max); } } return UnDefType.UNDEF; }