/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince) { setZonedDateTime(IF_UNMODIFIED_SINCE, ifUnmodifiedSince.withZoneSameInstant(GMT)); }
/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setIfModifiedSince(ZonedDateTime ifModifiedSince) { setZonedDateTime(IF_MODIFIED_SINCE, ifModifiedSince.withZoneSameInstant(GMT)); }
/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setLastModified(ZonedDateTime lastModified) { setZonedDateTime(LAST_MODIFIED, lastModified.withZoneSameInstant(GMT)); }
ZoneId zoneId_Norway = ZoneId.of( "Europe/Oslo" ); ZonedDateTime zdt_Norway = ZonedDateTime.of( 1985 , 1 , 1 , 3 , 2 , 1 , 0 , zoneId_Norway ); ZoneId zoneId_NewYork = ZonedId.of( "America/New_York" ); ZonedDateTime zdt_NewYork = zdt_Norway.withZoneSameInstant( zoneId_NewYork ); ZonedDateTime zdt_Utc = zdt_Norway.withZoneSameInstant( ZoneOffset.UTC ); // Or, next line is similar. Instant instant = zdt_Norway.toInstant(); // Instant is always in UTC. LocalDate localDate_Norway = zdt_Norway.toLocalDate();
@Override public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { final Instant instant = zonedDateTime.withZoneSameInstant(ZoneOffset.UTC).toInstant(); final Date date = Date.from(instant); jsonGenerator.writeObject(date); } }
private ZonedDateTime sameInstantInActualTimeZone(ZonedDateTime zonedDateTime) { if (zonedDateTime == null) return null; // nothing to convert in actual's TZ if (actual == null) return zonedDateTime; // no actual => let's keep zonedDateTime as it is. return zonedDateTime.withZoneSameInstant(actual.getZone()); }
/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setIfModifiedSince(ZonedDateTime ifModifiedSince) { setZonedDateTime(IF_MODIFIED_SINCE, ifModifiedSince.withZoneSameInstant(GMT)); }
/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince) { setZonedDateTime(IF_UNMODIFIED_SINCE, ifUnmodifiedSince.withZoneSameInstant(GMT)); }
/** * Set the time the resource was last changed, as specified by the * {@code Last-Modified} header. * @since 5.1.4 */ public void setLastModified(ZonedDateTime lastModified) { setZonedDateTime(LAST_MODIFIED, lastModified.withZoneSameInstant(GMT)); }
private ZonedDateTime sameInstantInActualTimeZone(ZonedDateTime zonedDateTime) { if (zonedDateTime == null) return null; // nothing to convert in actual's TZ if (actual == null) return zonedDateTime; // no actual => let's keep zonedDateTime as it is. return zonedDateTime.withZoneSameInstant(actual.getZone()); }
public void setTimeZone(ZoneId timeZone) { if (timestampTZ != null) { timestampTZ.setZonedDateTime( timestampTZ.getZonedDateTime().withZoneSameInstant(timeZone)); } this.timeZone = timeZone; }
public boolean isTickTime(ZonedDateTime currentDateTime) { LocalDate userDate = currentDateTime.withZoneSameInstant(tzName).toLocalDate(); int dayOfWeek = userDate.getDayOfWeek().getValue(); return ArrayUtil.contains(days, dayOfWeek); }
@Override public Object set(Object o, TimestampTZ t) { if (t == null) { return null; } ((TimestampTZ) o).setZonedDateTime( t.getZonedDateTime().withZoneSameInstant(((TimestampLocalTZTypeInfo) typeInfo).timeZone())); return o; }
private DateTimeValue( ZonedDateTime value ) { ZoneId zone = value.getZone(); if ( zone instanceof ZoneOffset ) { this.value = value; } else { // Do a 2-way lookup of the zone to make sure we only use the new name of renamed zones ZoneId mappedZone = ZoneId.of( TimeZones.map( TimeZones.map( zone.getId() ) ) ); this.value = value.withZoneSameInstant( mappedZone ); } this.epochSeconds = this.value.toEpochSecond(); }
@Override public Object set(Object o, TimestampLocalTZWritable t) { if (t == null) { return null; } ((TimestampTZ) o).setZonedDateTime( t.getTimestampTZ().getZonedDateTime().withZoneSameInstant(((TimestampLocalTZTypeInfo) typeInfo).timeZone())); return o; }
@Override public TimestampTZ getPrimitiveJavaObject(Object o) { if (o == null) { return null; } TimestampTZ t = (TimestampTZ) o; TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setZonedDateTime( t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone())); } return t; } }
@Override public Object set(Object o, TimestampTZ t) { if (t == null) { return null; } TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone())); } ((TimestampLocalTZWritable) o).set(t); return o; }
@Override public TimestampLocalTZWritable getPrimitiveWritableObject(Object o) { if (o == null) { return null; } TimestampTZ t = (TimestampTZ) o; TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setZonedDateTime( t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone())); } return new TimestampLocalTZWritable(t); }
@Override public TimestampTZ getPrimitiveJavaObject(Object o) { if (o == null) { return null; } TimestampTZ t = ((LazyTimestampLocalTZ) o).getWritableObject().getTimestampTZ(); TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone())); } return t; }
@Override public Object set(Object o, TimestampLocalTZWritable t) { if (t == null) { return null; } TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; if (!t.getTimestampTZ().getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) { t.getTimestampTZ().setZonedDateTime( t.getTimestampTZ().getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone())); } ((TimestampLocalTZWritable) o).set(t); return o; }