这里有一个Java 8库:
https://github.com/gkopff/gson-javatime-
serialisers
<dependency> <groupId>com.fatboyindustrial.gson-javatime-serialisers</groupId> <artifactId>gson-javatime-serialisers</artifactId> <version>1.1.1</version></dependency>
这是一个如何驱动它的简单示例:
Gson gson = Converters.registerOffsetDateTime(new GsonBuilder()).create();SomeContainerObject original = new SomeContainerObject(OffsetDateTime.now());String json = gson.toJson(original);SomeContainerObject reconstituted = gson.fromJson(json, SomeContainerObject.class);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)