@Override public LocalDateTime next(TransformationContext context) { if(direction.equals(Direction.ASCENDING)) { return LocalDateTime.ofInstant(Instant.ofEpochMilli(current.getAndAdd(step.toMillis())), this.offset.normalized()); } else { return LocalDateTime.ofInstant(Instant.ofEpochMilli(current.getAndAdd(step.toMillis() * -1)), this.offset.normalized()); } } }
/** * Parses date using the provided format to create * {@link OffsetDateTime} instances. * @param date The date to parse. * @param format The format to use. * @param offset The offset to use. */ public OffsetDateTimeOf(final CharSequence date, final String format, final ZoneOffset offset) { this(date, DateTimeFormatter.ofPattern(format).withZone(offset.normalized()) ); }
/** * Parses date using the provided format to create * {@link OffsetDateTime} instances. * @param date The date to parse. * @param format The format to use. * @param offset The offset to use. */ public OffsetDateTimeOf(final CharSequence date, final String format, final ZoneOffset offset) { this(date, DateTimeFormatter.ofPattern(format).withZone(offset.normalized()) ); }
@Override public LocalDateTime getLastCheckedTime(IDMEntityType<?> entityType) { if (entityType == null) { throw new IllegalArgumentException("entityType is null"); } SettingValue<?> settingValue = settingService.get(Context.GLOBAL, IDM_SCOPE, "DATE-" + entityType.getClassType().getSimpleName()); if (settingValue == null) { return null; } else { Object value = settingValue.getValue(); long timestamp; if (value instanceof Long) { timestamp = (Long) value; } else if (value instanceof String) { timestamp = Long.parseLong(String.valueOf(value)); } else { LOG.warn("value of type" + value.getClass().getSimpleName() + " is not recognized"); return null; } LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC.normalized()); return dateTime; } }