Java Date to UTC using gson

后端 未结 4 479
死守一世寂寞
死守一世寂寞 2020-12-05 00:04

I can\'t seem to get gson to convert a Date to UTC time in java.... Here is my code...

Gson gson = new GsonBuilder().setDateFormat(\"yyyy-MM-dd\'T\'HH:mm:ss.         


        
4条回答
  •  囚心锁ツ
    2020-12-05 00:40

    The Z in your dateformat is in single-quotes, it must be unquoted to be replaced by the actual timezone.

    Furthermore, if you want your date in UTC, convert it first.

提交回复
热议问题