简体   繁体   中英

How to validate that date in future in reference to another date?

I have following bean:

class CampaignBeanDto {

    @Future
    Date startDate;

    Date endDate;

    ...
}

Obviously I that endDate should be after startDate. I want to validate it.

I know that I can manually realize annotation for @FutureAfterDate , validator for this and initialize threshold date manually but I want to use @Validated spring mvc annotation.

How can I achieve it?

You're gonna have to bear down and write yourself a Validator.

This should get you started:

Cross field validation with Hibernate Validator (JSR 303)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM