FutureOrPresent not working for today... how to set the constraint to DAY or YEAR?

Greetings,

We apologize for the late reply. We hope this reply will helps you.

Time & syscalls problem

First of all, can you answer - do you use windows for development?

This issue is casual question for all our forums, this happens because modern OS is not “real-time” systems.
Syscalls on unix and windows are different in their conventions and we can see problems like problem below:

var localDateTimeNow = LocalDateTime.now();
var localDateTimeNowTwo = LocalDateTime.now();
assert localDateTimeNow != localDateTimeNowTwo
  • For unix nothing will happen
  • For windows - we will get exception

Java Bean validation implementation

In Bean Validation nothing checks for opertaion system, so we have a different behaviour in different OSs.

Solution

Yes, easest way to fix this is reimplement your own bean validation factory and validator behaviour.
Like in float comparation, in date-time comparation shoud not use EQUALS operation. Instead of it, use delta and compare this expression(pseudo-code):

abs(nowTimestamp - yourTimestamp) < delta
abs(1000000000 - 1000000001) < 0.01

Or other way to fix this

  • use @Past instead of @PastOrPresent validation.
  • wait for this issue that i created (Github Issue)

Regards,
Jmix team