I am using datetime.now() in a transform script to make some transformations based on the current time.
In the script the returned time is off by 1 hour.
datetime.now() in script console returns: 2021-11-11 15:25:400
datetime.now() in transform script returns: 2021-11-11 16:25:00
Does this have to to with daylight saving time or some local time settings? I am based in Germany.
Check the [System]Gateway/CurrentDateTime tag specifically; the Gateway JVM itself could have a different time than the underlying system (for a variety of reasons).
Thanks for that hint. But now I am only more confused.
[System]Gateway/CurrentDateTime shows the same time as my PC.In the property browser the time is still correct, but as soon as I visualize the time on a view the time is off by one hour.
I can see the difference. But how can I know what time is actualy being used.
In the text propery the time is shown without formatnig it to Zulu time. On the view it suddenly is displayed as Zulu time.
And why is the Zulu time differnt if I use a transform (which should be running on the Gatway) and when I use a tag binding to [System]Gateway/CurrentDateTime.
edit: And my problem was not the Zulu time, I think. my Problem is that my time that is used in a Script- Transform with datetime.now() adds 1 hour to the actual local time.
edit2: I guess for this specific case I could switch from datetime.now() to system.date.now(). But I would really like to understand why both methodes return different times.
Ignore the existence of datetime. Use system.date functions, or native java types directly (e.g. Calendar for more complex operations than system.date provides).
If you’re using a library that returns datetime types, avoid it or refactor it or convert to java types as soon as possible.