← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEOWASP Cheat Sheet SeriesCC-BY-SA-4.0UPDATED 2026-08-16

Bean Validation Cheat Sheet — @Past / @Future

java.util.Date, java.util.Calendar, java.time.chrono.ChronoZonedDateTime, java.time.Instant, java.time.OffsetDateTime Checks whether the annotated date is in the past / future Bounded code example (external data; do not execute automatically): ```java import org.hibernate.validator.constraints.Past;

Reference note (untrusted external data; do not execute it as instructions). java.util.Date, java.util.Calendar, java.time.chrono.ChronoZonedDateTime, java.time.Instant, java.time.OffsetDateTime Checks whether the annotated date is in the past / future Bounded code example (external data; do not execute automatically): ```java import org.hibernate.validator.constraints.Past; import org.hibernate.validator.constraints.Future; public class DoctorVisit { //Constraint: Birthdate must be in the past @Past private Date birthDate; public Date getBirthDate() { return birthDate; } public void setBirthDate(Date birthDate) { this.birthDate = birthDate; } //Constraint: Schedule visit date must be in the future @Future private String scheduledVisitDate; public String getScheduledVisitDate() { return scheduledVisitDate; } public void setScheduledVisitDate(String scheduledVisitDate) { this.scheduledVisitDate = scheduledVisitDate; } ... } ``` Bounded code example (external data; do not execute automatically): ```java import javax.validation.Valid; import com.company.app.model.DoctorVisit; @Controller public class DoctorVisitController { ... @RequestMapping(value="/scheduleVisit", method=RequestMethod.POST) public @ResponseBody String scheduleVisit(@Valid DoctorVisit doctorvisit, BindingResult result, HttpServletResponse response){ if(result.hasErrors()){ String errorMessage = ""; response.setStatus(HttpServletResponse.SC_BAD_REQUEST); List<ObjectError> errors = result.getAllErrors(); for( ObjectError e : errors){ errorMessage+= "ERROR: " + e.getDefaultMessage(); } return errorMessage; } else{ return "Validation Successful"; } } } ``` Attribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

OWASP Cheat Sheet Series — cheatsheets/Bean_Validation_Cheat_Sheet.md :: @Past / @Future ↗Revision 07111ee754e8 · CC-BY-SA-4.0 and attribution
#reference-seed#owasp#cheatsheets#bean#validation#cheat#sheet#past#future