1 package fr.ifremer.quadrige2.synchro.server.technical;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import fr.ifremer.quadrige2.core.dao.technical.gson.Gsons;
27 import org.apache.commons.lang3.StringUtils;
28 import org.springframework.beans.factory.InitializingBean;
29 import org.springframework.http.HttpInputMessage;
30 import org.springframework.http.converter.HttpMessageNotReadableException;
31
32 import java.io.IOException;
33 import java.lang.reflect.Type;
34 import java.util.TimeZone;
35
36
37
38
39
40
41
42
43
44 public class GsonHttpMessageConverter extends org.springframework.http.converter.json.GsonHttpMessageConverter
45 implements InitializingBean {
46
47 private String timezone = null;
48
49 public GsonHttpMessageConverter() {
50 super();
51 }
52
53 public void setTimezone(String timezone) {
54 this.timezone = timezone;
55 }
56
57 @Override
58 public void afterPropertiesSet() throws Exception {
59
60
61 TimeZone tz = StringUtils.isNotBlank(timezone) ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault();
62 setGson(Gsons.newBuilder(tz).create());
63 }
64 }