Reputation: 944
When I use the OffsetDateTime.now()
in my unit tests I receive the same time as I see on my clock hanging on the wall.
But when it comes to deploy app and debug I see this time -2h hours.
How do I deal with this?
Also, how to treat this execution time, if a user can do the same thing and they come from many different places?
How can I execute something now()
if I come from other localization?
Upvotes: 0
Views: 418
Reputation: 2255
Use this now
method to get rid of dependency on time zone of server. Pass either a ZoneId
object or a ZoneOffset
object.
public static OffsetDateTime now(ZoneId zone)
Upvotes: 4