@Override public KVValue visit(BsonDateTime value, Void arg) { if (value instanceof InstantBsonDateTime) { return new InstantKVInstant(value.getValue()); } return new LongKVInstant(value.getMillisFromUnix()); }
public static BsonTimestamp toTimestamp(BsonDateTime dateTime, BiFunction<Integer, Integer, BsonTimestamp> tsCreator) { long millisFromUnix = dateTime.getMillisFromUnix(); int secs = (int) (millisFromUnix >> 32); int ordinal = (int) (millisFromUnix & 0xFFFFFFFF); return tsCreator.apply(secs, ordinal); }
@Nonnull public static Instant getInstant(Entry<?> entry, String fieldId) throws TypesMismatchException { BsonValue<?> value = entry.getValue(); if (!value.isDateTime()) { throw new TypesMismatchException( fieldId, "date", value.getType(), "Expected date type for field " + fieldId + ". Found" + value ); } return value.asDateTime().getValue(); }
@Override public Void visit(BsonDateTime value, ByteBuf arg) { arg.writeLong(value.getMillisFromUnix()); return null; }
@Override public int compareTo(BsonValue<?> obj) { if (obj == this) { return 0; } int diff = BsonTypeComparator.INSTANCE.compare(getType(), obj.getType()); if (diff != 0) { return diff; } assert obj instanceof BsonDateTime; BsonDateTime other = obj.asDateTime(); return this.getValue().compareTo(other.getValue()); }
@Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof BsonDateTime)) { return false; } return this.getMillisFromUnix() == ((BsonDateTime) obj).getMillisFromUnix(); }
.getMillisFromUnix()); case DB_POINTER: { com.eightkdata.mongowp.bson.BsonDbPointer casted =