Hibernate-Search:如何搜索日期?
@Entity
@Table(name = "USERS")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "USERNAME", nullable = false, length = 20)
private String userName;
@Column(name = "PASSWORD", nullable = false, length = 10)
private String password;
@Column(name = "Date", nullable = false )
private Date date;
}
如何选择日期在
- [现在 | 之间] 之间的记录现在-x小时]
- [现在|现在-x天]
- [现在|现在-x个月]
- [现在|现在-x年]
@Entity
@Table(name = "USERS")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "USERNAME", nullable = false, length = 20)
private String userName;
@Column(name = "PASSWORD", nullable = false, length = 10)
private String password;
@Column(name = "Date", nullable = false )
private Date date;
}
How can I select the records which have the date between
- [now | now-x hours]
- [now | now-x days]
- [now | now-x months]
- [now | now-x years]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其他字段相同的方式:<= >= 或之间等,
您可以使用 commons-lang / DateUtils 来修改日期。
the same way as with the other fields: <= >= or between etc
you can use commons-lang / DateUtils to modify the date.