/** * Converts this date-time to an {@code Instant}. * * @return an {@code Instant} representing the same instant, not null */ public Instant toInstant() { return dateTime.toInstant(offset); }
/** * Converts this date-time to an {@code Instant}. * * @return an {@code Instant} representing the same instant, not null */ public Instant toInstant() { return dateTime.toInstant(offset); }
/** * Gets the transition instant. * <p> * This is the instant of the discontinuity, which is defined as the first * instant that the 'after' offset applies. * <p> * The methods {@link #getInstant()}, {@link #getDateTimeBefore()} and {@link #getDateTimeAfter()} * all represent the same instant. * * @return the transition instant, not null */ public Instant getInstant() { return transition.toInstant(offsetBefore); }
/** * Gets the transition instant. * <p> * This is the instant of the discontinuity, which is defined as the first * instant that the 'after' offset applies. * <p> * The methods {@link #getInstant()}, {@link #getDateTimeBefore()} and {@link #getDateTimeAfter()} * all represent the same instant. * * @return the transition instant, not null */ public Instant getInstant() { return transition.toInstant(offsetBefore); }
@Nullable public static Long localDateTimeToLongUtc(@Nullable LocalDateTime d) { if (d == null) { return null; } return d.toInstant(ZoneOffset.UTC).toEpochMilli(); }
@Override public BsonValue visit(DateValue value, Void arg) { Instant instant = value.getValue().atStartOfDay().toInstant(ZoneOffset.UTC); return new BsonDateTime(instant.toEpochMilli()); }
@Override public BsonValue visit(DateTimeValue value, Void arg) { Instant instant = value.getValue().toInstant(ZoneOffset.UTC); return new BsonTimestamp( UnsignedInteger.valueOf(instant.getEpochSecond()).intValue(), instant.getNano() ); }