Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.04 KB

README.md

File metadata and controls

34 lines (23 loc) · 1.04 KB

gson-javatime-serialisers

What is it?

A set of GSON serialiser/deserialisers for dealing with Java 8 java.time entities. Wherever possible, ISO 8601 string representations are used.

Getting it

<dependency>
  <groupId>com.fatboyindustrial.gson-javatime-serialisers</groupId>
  <artifactId>gson-javatime-serialisers</artifactId>
  <version>1.1.2</version>
</dependency>

Using it

final Gson gson = Converters.registerOffsetDateTime(new GsonBuilder()).create();
final OffsetDateTime original = OffsetDateTime.now();

final String json = gson.toJson(original);
final OffsetDateTime reconstituted = gson.fromJson(json, OffsetDateTime.class);

Testing

Unrelated to gson-javatime-serialisers itself, but if you're working with Java 8 time, you may be interested in spencerwi/hamcrest-jdk8-time