本文整理汇总了Java中org.bson.BsonType.DATE_TIME属性的典型用法代码示例。如果您正苦于以下问题:Java BsonType.DATE_TIME属性的具体用法?Java BsonType.DATE_TIME怎么用?Java BsonType.DATE_TIME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bson.BsonType
的用法示例。
在下文中一共展示了BsonType.DATE_TIME属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
static LocalDateTime read(BsonReader reader, String field) {
BsonType currentType = reader.getCurrentBsonType();
if (currentType == BsonType.NULL) {
reader.readNull();
return null;
} else if (currentType == BsonType.DATE_TIME) {
return LocalDateTime.ofInstant(Instant.ofEpochMilli(reader.readDateTime()), ZoneId.systemDefault());
} else {
LOGGER.warn("unexpected field type, field={}, type={}", field, currentType);
reader.skipValue();
return null;
}
}
示例2: read
static ZonedDateTime read(BsonReader reader, String field) {
BsonType currentType = reader.getCurrentBsonType();
if (currentType == BsonType.NULL) {
reader.readNull();
return null;
} else if (currentType == BsonType.DATE_TIME) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(reader.readDateTime()), ZoneId.systemDefault());
} else {
LOGGER.warn("unexpected field type, field={}, type={}", field, currentType);
reader.skipValue();
return null;
}
}
示例3: isCompExtensionFilterPassed
private boolean isCompExtensionFilterPassed(String type, String comp, BsonArray paramArray, BsonDocument ext) {
type = MongoWriterUtil.encodeMongoObjectKey(type);
Iterator<String> keyIterator = ext.keySet().iterator();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
BsonValue sub = ext.get(key);
if (key.equals(type)) {
for (int i = 0; i < paramArray.size(); i++) {
BsonValue param = paramArray.get(i);
if (sub.getBsonType() == param.getBsonType()) {
if (sub.getBsonType() == BsonType.INT32) {
if (comp.equals("GT")) {
if (sub.asInt32().getValue() > param.asInt32().getValue())
return true;
} else if (comp.equals("GE")) {
if (sub.asInt32().getValue() >= param.asInt32().getValue())
return true;
} else if (comp.equals("LT")) {
if (sub.asInt32().getValue() < param.asInt32().getValue())
return true;
} else if (comp.equals("LE")) {
if (sub.asInt32().getValue() <= param.asInt32().getValue())
return true;
}
} else if (sub.getBsonType() == BsonType.INT64) {
if (comp.equals("GT")) {
if (sub.asInt64().getValue() > param.asInt64().getValue())
return true;
} else if (comp.equals("GE")) {
if (sub.asInt64().getValue() >= param.asInt64().getValue())
return true;
} else if (comp.equals("LT")) {
if (sub.asInt64().getValue() < param.asInt64().getValue())
return true;
} else if (comp.equals("LE")) {
if (sub.asInt64().getValue() <= param.asInt64().getValue())
return true;
}
} else if (sub.getBsonType() == BsonType.DOUBLE) {
if (comp.equals("GT")) {
if (sub.asDouble().getValue() > param.asDouble().getValue())
return true;
} else if (comp.equals("GE")) {
if (sub.asDouble().getValue() >= param.asDouble().getValue())
return true;
} else if (comp.equals("LT")) {
if (sub.asDouble().getValue() < param.asDouble().getValue())
return true;
} else if (comp.equals("LE")) {
if (sub.asDouble().getValue() <= param.asDouble().getValue())
return true;
}
} else if (sub.getBsonType() == BsonType.DATE_TIME) {
if (comp.equals("GT")) {
if (sub.asDateTime().getValue() > param.asDateTime().getValue())
return true;
} else if (comp.equals("GE")) {
if (sub.asDateTime().getValue() >= param.asDateTime().getValue())
return true;
} else if (comp.equals("LT")) {
if (sub.asDateTime().getValue() < param.asDateTime().getValue())
return true;
} else if (comp.equals("LE")) {
if (sub.asDateTime().getValue() <= param.asDateTime().getValue())
return true;
}
}
}
}
return false;
}
if (sub.getBsonType() == BsonType.DOCUMENT) {
if (isCompExtensionFilterPassed(type, comp, paramArray, sub.asDocument()) == true) {
return true;
}
}
}
return false;
}