Skip to content

A set of GSON serialiser/deserialisers for dealing with Java 8 java.time entities.

License

Notifications You must be signed in to change notification settings

fedxyz/gson-javatime-serialisers

 
 

Repository files navigation

This is a fork of the original project, I only added YearMonth support. Next you can read the original README.

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

About

A set of GSON serialiser/deserialisers for dealing with Java 8 java.time entities.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%