Hi Timothy, Um, you are being very polite, but the framework needs to be more sophisticated here. Basically for DateTime we should be honouring the timezone of the caller, whereas the timezone is fixed on the server (as you say, to UTC).
All is not lost however. You can replace the default ClockService with your own implementation; just make sure that @DomainServiceLayout(menuOrder="100") or some other low number. This will then take priority over the default implementation. See [1] You should be able to put together an implementation that reaches down to the servlet api (eg using [2]) in order to honour the caller. you'll need some sort of fallback when running integration tests, of course, because there won't be any servlet container to call to. If the above design sketch works out, then we'll use it to fold back into the framework. HTH Dan [1] https://isis.apache.org/guides/rgsvc.html#_rgsvc_intro_overriding-the-services [2] https://github.com/isisaddons/isis-module-servletapi On Wed, 22 Feb 2017 at 18:13 Simecsek Timothy <[email protected]> wrote: > Hi all, > > I have an issue with the ClockService in my application. My machine is > running on Europe/Berlin timezone (CET). > > Following my use case - observed while debugging my code: > I created a DomainObject with properties validFrom and validTo (both joda > DateTime objects) and used clockService.nowAsDateTime() to initialize them, > when I inspected the resulting object both properties had timezone UTC, but > on UI the time was displayed correctly according to my machines timezone. > BUT: Once I persisted the DomainObject, reloaded it using > RepositoryService and inspected the object's properties again they had > Europe/Berlin timezone. So the behavior is inconsistent. > By the way nowAsJavaSqlTimestamp() returns the correct time! > > The problem is valid both for running integration tests and jetty. > > I found that the ClockService (or to be more specific Clock) uses > org.apache.isis.applib.Defaults to get the timezone and Defaults uses UTC. > When I use Defaults.setTimeZone(DateTimeZone.getDefault()); while running > integration tests it works as expected. > > Currently I'm using Apache ISIS 1.13.2 with H2 in memory database. > > Do I miss any configuration property or am I using ClockService wrong? > > Thanks & Regards Timothy > > ______________________________________________________________________ > Disclaimer: This email and any attachments are sent in strictest confidence > for the sole use of the addressee and may contain legally privileged, > confidential, and proprietary data. If you are not the intended recipient, > please advise the sender by replying promptly to this email and then delete > and destroy this email and any attachments without any further use, copying > or forwarding.
