Google app engine - local time zone of the development server

I understood from the GAE documentation that the time zone of a production server is always UTC. With local development, the server time zone is set to CET. Is there a way to make the local development server also work in UTC?

The development server runs on Mac OS.

Thanks,

Gyug

+4
source share
3 answers

found the answer. To set the time zone of the server, just go to Eclipse, "Run the configuration", then "VM Arguments" and add the following "-Duser.timezone = UTC".

In this case, the serverโ€™s time zone will be set to the desired value (UTC). This is very convenient, since UTC will always work in Google App Engine, while the development server (at least in my case) works with the local time zone. The net effect was that I had a different behavior between dev and prod.

Gyug

+4
source

Well, you can use this by storing the date value in your data store to convert it to a specific time zone.

DateFormat utcFormat = new SimpleDateFormat(patternString); utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); DateFormat indianFormat = new SimpleDateFormat(patternString); utcFormat.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata")); Date timestamp = utcFormat.parse(inputString); String output = indianFormat.format(timestamp); 
+2
source

GAE devServer uses the local time zone by default.

I use this code to force it to UTC:

 boolean isDevEnvironment = SystemProperty.environment.value() == SystemProperty.Environment.Value.Development; if (isDevEnvironment) { TimeZone.setDefault(DateTimeZone.UTC.toTimeZone()); DateTimeZone.setDefault(DateTimeZone.UTC); } 

You need to run it once, during server startup and initialization.

+1
source

Source: https://habr.com/ru/post/1444560/


All Articles