如何在数据存储中使用 Date 属性的对象化进行过滤



如何使用 Date 属性的对象化在数据存储中进行过滤?我有一个看起来像下面的实体 pojo 类.在此时间戳中,是一个保存日期值的属性。

public class TravelEntry {
    private String deviceId;
    private String pushedGeoData;
    private String location;
    private Date timeStamp;
    public TravelEntry(){
        setTimeStamp(this.timeStamp);
    }
    public String getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }
    public String getPushedGeoData() {
        return pushedGeoData;
    }
    public void setPushedGeoData(String pushedGeoData) {
        this.pushedGeoData = pushedGeoData;
    }
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
    public Date getTimeStamp() {
        return timeStamp;
    }
    public void setTimeStamp(Date timeStamp) {
        if(timeStamp==null){
            this.timeStamp = new Date();
        }else{
            this.timeStamp = timeStamp;
        }
    }
}

如何使用对象化查询或筛选日期属性?我想检索所有具有特定日期和时间的实体。

这一切都在文档中详细说明:

https://code.google.com/p/objectify-appengine/wiki/Queries

@Index该字段,然后按所需的日期值进行筛选。

最新更新