TimeZone and dateEquals filter

Hello,

I’ve encountered very annoying problems when trying to filter DateTime column for entities in a specified day. The only way I came up with was using custom filter and dateEquals, but neither macro, nor the component respect user’s timezone. Scenario:

  1. DB + JAVA Server in UTC
  2. User is in GMT+1
  3. Filter field with java.sql.Date as paramClass
  4. Instead of filtering between 00:00 and 23:59 of users timezone, it filters the same range in server’s timezone - user gets results between 1:00 and 00:59 of the next day

We needed to fix it by overriding com.haulmont.cuba.gui.components.filter.Param and com.haulmont.cuba.core.sys.querymacro.DateEqualsMacroHandler. Cuba handles user’s TimeZone in other place well, this is a real shame!

1 Like

Hi Jan,

Could you share your code or make a pull request?

Hello Konstantin,

my colleague create a pull request, feel free to integrate it:

One test is not passing anymore. I think it is due to non initialized AppContext.

Thank you. Please see my comments in the PR discussion. There is also a related issue.

Fair enough. We sadly do not have time to go through other truncating macros and as this was irritating our customer we had to deal with it somehow. I hope the PR have helped you a bit.

Sure, it clearly defines the problem and a possible solution. But I have no idea at the moment how to save other use cases with date parameter from breaking.