开发者

Hibernate-Search: How to search dates?

开发者 https://www.devze.com 2022-12-27 08:01 出处:网络
@Entity @Table(name = \"USERS\") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO)
@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;

 @Colu开发者_运维问答mn(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]


the same way as with the other fields: <= >= or between etc

you can use commons-lang / DateUtils to modify the date.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号