java hibernate 校验,用Hibernate验证日期

在酒店管理系统中,需要为'创建住宿'功能添加日期验证。当前'结束日期'已通过Hibernate的@Future注解进行未来日期验证。新增需求是'开始日期'应允许当前或未来日期,但Hibernate的@Future不接受今天。解决方案包括使用Hibernate的@CreationTimestamp或@UpdateTimestamp,或者创建自定义的@PresentOrFuture注解和对应的验证器。
摘要由CSDN通过智能技术生成

We have an existing hotel management system. I was asked to add a date validation in the "Create Accommodation" function in the system. The dialog looks like this:

zy7Ce.png

The "End Date" is already validated as shown in the code below. The @Future annotation in Hibernate ensures that the date is in the future.

@NotNull

@Future

@DateTimeFormat(pattern = "dd/MM/yyyy")

@Temporal(TemporalType.DATE)

private Date endDate;

EDIT

I was asked to add a validation to the "Start date". Only the present or a future date is allowed. I tried to use a @Present annotation, but I guess there is no such thing. Unfortunately, @Future does not accept today's date. I am new to this kind of thing. So I hope some

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值