如何使用 objectify 过滤数据存储中的日期 属性?
How to filter in datastore using objectify for a Date property ?
如何使用 objectify 过滤数据存储中的日期 属性?
我有一个看起来像下面 pojo class 的实体。在此 timeStamp 中,属性 包含 Date 值。
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;
}
}
}
如何使用 Objectify 查询或过滤日期 属性?
我想检索特定日期和时间的所有实体。
文档中都写明了:
https://code.google.com/p/objectify-appengine/wiki/Queries
@Index
字段,然后按所需的日期值过滤。
如何使用 objectify 过滤数据存储中的日期 属性? 我有一个看起来像下面 pojo class 的实体。在此 timeStamp 中,属性 包含 Date 值。
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;
}
}
}
如何使用 Objectify 查询或过滤日期 属性? 我想检索特定日期和时间的所有实体。
文档中都写明了:
https://code.google.com/p/objectify-appengine/wiki/Queries
@Index
字段,然后按所需的日期值过滤。