如何查询Gemfire中设置的时间戳长度


public class Employee {
private String name; 
private long timestamp; 
}

时间戳以长格式保存。转换后将为2021-11-19T21:00 37.353+0000

用户输入仅为2021-11-19,我们如何忽略时间/时区进行查询,查询日期的正确方式是什么?

Gemfire查询

select * from /employee where to_date(timestamp) = to date(2021-21-19)
Error -> Query is invalid due to error - Syntax error in query - unexpected token-timestamp

看起来您的查询表达式是错误的。根据文档中的预设查询函数,TO_DATE函数需要两个参数:使用java.text.SimpleDateFormat类将String转换为Date时要解析的实际值和要使用的字符串格式。

不过,我不确定是否有支持的格式可用于您的情况,因此您可能需要在域对象或OQL本身中做一些额外的操作,以便从timestamp字段中获得Date表示。

干杯。

最新更新