0

I'm using Scala along with play framework. So I've set my system timezone to UTC:

sudo systemsetup -gettimezone
Time Zone: GMT

But

println(DateTime.now().toString)

results into "2018-10-10T19:29:40.886+02:00" and all of the dates I operate in my code keep my actual timezone unless I set it manually by withZone. How do I set my system date properly? Would appreciate any help!

P.S. I'm using Postman for testing, so if there is a way to set it there it could also work...

anako
  • 125
  • 7
  • Wouldn’t it be better to set it manually by `withZone` (or whatever handles are in Joda-Time, it’s not my home field)? The JVM’s time zone setting can be changed at any time by other parts of your program or other programs running in the same JVM, so I wouldn’t be too comfortable relying on it. – Ole V.V. Oct 11 '18 at 09:46
  • Possible duplicate of [How to set a JVM TimeZone Properly](https://stackoverflow.com/questions/2493749/how-to-set-a-jvm-timezone-properly) – Ole V.V. Oct 11 '18 at 09:48

1 Answers1

2

You need to pass the JVM parameter: "-Duser.timezone=GMT" when starting your app.

If you start your app with sbt run, try:

env JAVA_OPTS="-Duser.timezone=GMT" sbt run

then the output for println(DateTime.now().toString)

is: 2018-10-10T18:20:45.386Z