@Override protected Value<Timestamp> saveValue(final ReadableInstant value, final SaveContext ctx, final Path path) throws SkipException { return TimestampValue.of(Timestamp.of(value.toInstant().toDate())); } };
@Override public Date convert(Instant in, Context context) throws Exception { if (in == null) return null; return in.toDate(); } }
public Date convertToDatabaseColumn(Instant instant) { return instant.toDate(); }
Instant instant = ...; Date date = instant.toDate(); instant = new Instant(date); // Or... instant = new Instant(date.getTime());
@Override public Object forDatastore(Object value, ConverterSaveContext ctx) { if (value instanceof ReadableInstant) return ((ReadableInstant)value).toInstant().toDate(); else return null; }
@Override public Date from(ReadableInstant from) { return from == null ? null : from.toInstant().toDate(); }
@Override public Date from(ReadableInstant from) { return from == null ? null : from.toInstant().toDate(); }
public Temporal(Instant time) { super(); this.id = getId(); this.time = time; this.dateTime = time.toDate(); this.timestamp = time.getMillis(); this.updateTime = new AtomicReference<Instant>(time); this.updateTimestamp = new AtomicLong(time.getMillis()); }
/** * Insert. */ @PrePersist public void onInsert() { setCreatedDate(Calendar.getInstance().getTime()); setLastUpdatedDate(Instant.now().toDate()); }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((Instant) value).toDate(), index); } }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.TIMESTAMP.nullSafeSet(preparedStatement, ((Instant) value).toDate(), index); } }
@SuppressWarnings("deprecation") public static void setDaysOfWeek () { Instant base = Competition.currentCompetition().getSimulationBaseTime(); int bias = Math.abs(base.toDate().getDay() - DAYS_OF_WEEK) % DAYS_OF_WEEK; MONDAY = (MONDAY + bias) % DAYS_OF_WEEK; TUESDAY = (TUESDAY + bias) % DAYS_OF_WEEK; WEDNESDAY = (WEDNESDAY + bias) % DAYS_OF_WEEK; THURSDAY = (THURSDAY + bias) % DAYS_OF_WEEK; FRIDAY = (FRIDAY + bias) % DAYS_OF_WEEK; SATURDAY = (SATURDAY + bias) % DAYS_OF_WEEK; SUNDAY = (SUNDAY + bias) % DAYS_OF_WEEK; }
@SuppressWarnings("deprecation") public static void setDaysOfWeek () { Instant base = Competition.currentCompetition().getSimulationBaseTime(); int bias = Math.abs(base.toDate().getDay() - DAYS_OF_WEEK) % DAYS_OF_WEEK; MONDAY = (MONDAY + bias) % DAYS_OF_WEEK; TUESDAY = (TUESDAY + bias) % DAYS_OF_WEEK; WEDNESDAY = (WEDNESDAY + bias) % DAYS_OF_WEEK; THURSDAY = (THURSDAY + bias) % DAYS_OF_WEEK; FRIDAY = (FRIDAY + bias) % DAYS_OF_WEEK; SATURDAY = (SATURDAY + bias) % DAYS_OF_WEEK; SUNDAY = (SUNDAY + bias) % DAYS_OF_WEEK; } }
@PreUpdate void onUpdate() { if (lastUpdatedDate == null) { setLastUpdatedDate(Instant.now().toDate()); } }
protected synchronized void setTime(Instant time) { this.time = time; this.dateTime = time.toDate(); this.time = time; setUpdateTime(time); setTimestamp(time.getMillis()); }
@PreUpdate void onUpdate() { setLastUpdatedDate(Instant.now().toDate()); }
GetMetricStatisticsRequest createMetricStatisticsRequest( String streamName, Instant countSince, Instant countTo, Minutes period) { return new GetMetricStatisticsRequest() .withNamespace(KINESIS_NAMESPACE) .withMetricName(INCOMING_RECORDS_METRIC) .withPeriod(period.getMinutes() * PERIOD_GRANULARITY_IN_SECONDS) .withStartTime(countSince.toDate()) .withEndTime(countTo.toDate()) .withStatistics(Collections.singletonList(SUM_STATISTIC)) .withDimensions( Collections.singletonList( new Dimension().withName(STREAM_NAME_DIMENSION).withValue(streamName))); }
public Record convertToRecord() { return new Record() .withApproximateArrivalTimestamp(arrivalTimestamp.toDate()) .withData(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8))) .withSequenceNumber(sequenceNumber) .withPartitionKey(""); }
@Test public void shouldReturnIteratorStartingWithTimestamp() throws Exception { Instant timestamp = Instant.now(); given( kinesis.getShardIterator( new GetShardIteratorRequest() .withStreamName(STREAM) .withShardId(SHARD_1) .withShardIteratorType(ShardIteratorType.AT_SEQUENCE_NUMBER) .withTimestamp(timestamp.toDate()))) .willReturn(new GetShardIteratorResult().withShardIterator(SHARD_ITERATOR)); String stream = underTest.getShardIterator( STREAM, SHARD_1, ShardIteratorType.AT_SEQUENCE_NUMBER, null, timestamp); assertThat(stream).isEqualTo(SHARD_ITERATOR); }