cuba icon indicating copy to clipboard operation
cuba copied to clipboard

Date validation errors with @FutureOrPresent and @PastOrPresent annotations

Open owlet1997 opened this issue 4 years ago • 2 comments

based on forum's question

Environment

  • Platform version: CUBA 7.2.15
  • Tomcat 9
  • Database: HSQLDB
  • OS: Ubuntu 20.04 LTS

Preconditions: install local tomcat server

Shared steps:

  1. Open attached project
  2. Deployment -> Create WAR
  3. Deploy WAR file as described here

TC 1:

  1. Open http://localhost:8080/app/ -> login as admin
  2. Open Parts browser -> Create new one -> Set present date to date fields with 'Future' prefixes -> Save

AR: validation error with date types: Date, OffsetDateTime, LocalDateTime

ER: entity had been successfully created

TC 2:

  1. Change system time to next day, 00:xx
  2. Open http://localhost:8080/app
  3. Open Parts browser -> Create new one -> Set present date to date fields with 'Past' prefixes -> Save

AR: validation error with all date types

ER: entity had been successfully created

owlet1997 avatar Oct 03 '21 18:10 owlet1997

@owlet1997 could you please check it in Jmix and create an issue there too?

knstvk avatar Oct 04 '21 06:10 knstvk

Seems that the problem is present in Cuba and Jmix since commit.

When validators created during context initialisation the ClockProvider provides clock with date fixed on application startup date. Since Hibernate DefaultClockProvider works well, I propose implementing ClockProvider the same way

VitaliiEv avatar Aug 31 '23 18:08 VitaliiEv