Hi, support team.
We’re using @PastOrPresent and @FutureOrPresent annotations to validate some date type attributes and we detected those anomalous behaviours when the date is today’s date:
-
With @FutureOrPresent always fails the validation showing the missage “must be in the future or in the present”
-
With @PastOrPresent:
-
This field validation works fine in localhost.
-
But when we compiled the app to a WAR file and deployed it to a Tomcat server, the date validation works fine until the 00:00 hour of next day. Since then, when the user introduces today’s date the validation fails showing the missage “must be in the past or in the present” and the most recent date that validation accepts is the date that Tomcat server started. There’s a post in the forum from one year ago that exposed same problem.
-
https://forum.cuba-platform.com/t/time-validation-error-without-any-apparent-reasons/13854
On the second subject, the @PastOrPresent related problems on the Tomcat server, probably are originated by some wrong server configuration. We would be very grateful if you give us some ideas about how to solve it.
Here you are our platform details:
Development environment:
CUBA Platform version: 7.2.13
CUBA Studio plugin version: 15.4-202
IntelliJ version: CUBA Studio 2020.2
Server version: Apache Tomcat/9.0.38
JVM : openjdk version “11.0.6” 2020-01-14 LTS. OpenJDK Runtime Environment 18.9 (build 11.0.6+10-LTS). OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10-LTS, mixed mode)
O.S. Windows 10 Pro version 1709
Time Zone: Europa Central (Central European Time)
Server environment:
O.S.: CentOS Linux version 7
Time zone: Europe/Madrid (CEST, +0200)
Server version: Apache Tomcat 9.0.27
JVM: openjdk version “11.0.6” 2020-01-14 LTS. OpenJDK Runtime Environment 18.9 (build 11.0.6+10-LTS). OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10-LTS, mixed mode, sharing)
Database: Oracle 12c
We have tested the @FutureOrPresent validation error with today’s date on different databases, Oracle 12c, Sql Server 2008 R2, HSQLDB, obtaining the same result: “must be in the future or in the present”.
Attached to this post, there’s a test project with HSQLDB database, which reproduce the error, to help you to test the validation problem with today’s date and @FutureOrPresent validation.
datevalidation.zip (1.7 MB)
Debugging code, we detected that date datatype is java.sql.date although the datatype definition on data model class was java.util.date. Then, in “CubaFutureOrPresentValidatorForDate” class the parameter value received is today’s date with 00:00:00 time, for example “2021-09-29T00:00:00Z”, but the value returned is yesterday date with “22:00:00” time, in this case “2021-09-28T22:00:00Z”. With this returned value doesn’t pass validation because is in the past.
We would be very grateful to receive any ideas to solve those problems with date validations.
Thanks in advance.