ThreeTen BackPort Gson Adapter

A library provides Json serialization/deserialization support for JSR-310 backport types using Gson

License

License

Categories

Categories

Gson Data JSON
GroupId

GroupId

org.aaronhe
ArtifactId

ArtifactId

threetenbp-gson-adapter
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

ThreeTen BackPort Gson Adapter
A library provides Json serialization/deserialization support for JSR-310 backport types using Gson
Project URL

Project URL

https://github.com/aaronhe42/ThreeTen-Backport-Gson-Adapter
Source Code Management

Source Code Management

https://github.com/aaronhe42/ThreeTen-Backport-Gson-Adapter

Download threetenbp-gson-adapter

How to add to project

<!-- https://jarcasting.com/artifacts/org.aaronhe/threetenbp-gson-adapter/ -->
<dependency>
    <groupId>org.aaronhe</groupId>
    <artifactId>threetenbp-gson-adapter</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.aaronhe/threetenbp-gson-adapter/
implementation 'org.aaronhe:threetenbp-gson-adapter:1.0.2'
// https://jarcasting.com/artifacts/org.aaronhe/threetenbp-gson-adapter/
implementation ("org.aaronhe:threetenbp-gson-adapter:1.0.2")
'org.aaronhe:threetenbp-gson-adapter:jar:1.0.2'
<dependency org="org.aaronhe" name="threetenbp-gson-adapter" rev="1.0.2">
  <artifact name="threetenbp-gson-adapter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.aaronhe', module='threetenbp-gson-adapter', version='1.0.2')
)
libraryDependencies += "org.aaronhe" % "threetenbp-gson-adapter" % "1.0.2"
[org.aaronhe/threetenbp-gson-adapter "1.0.2"]

Dependencies

compile (2)

Group / Artifact Type Version
org.threeten : threetenbp jar 1.3
com.google.code.gson : gson jar 2.5

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

ThreeTen Backport Gson Adapter

A library provides serialization/deserialization support for JSR-310 backport types using Gson.

Currently supports Instant, LocalDate, LocalTime, LocalDateTime, OffsetDate, OffsetTime and ZonedDateTime.

Usage

Use one or some of static methods in ThreeTenGsonAdapter to register type adapter on GsonBuilder object.

For example, if you'd like Gson to serialize/deserialize LocalTime, register LocalTime using ThreeTenGsonAdapter like this:

GsonBuilder builder = new GsonBuilder();
Gson gson = ThreeTenGsonAdapter.registerLocalTime(builder).create();

If you need all of the supported types, there's a convenient method: ThreeTenGsonAdapter.registerAll().

Build

To build:

$ git clone [email protected]:aaronhe42/ThreeTen-Backport-Gson-Adapter.git
$ cd ThreeTen-Backport-Gson-Adapter/
$ ./gradlew build

Build Status

Download

compile 'org.aaronhe:threetenbp-gson-adapter:1.0.2'

Snapshots of the development version are available in Sonatype's snapshots repository.

If your project uses a library other than threetenbp which actually provides the ThreeTen Backport, like ThreeTenABP, you need to exclude threetenbp library from the dependency. Otherwise UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lorg/threeten/bp/Clock will be thrown.

compile('org.aaronhe:threetenbp-gson-adapter:1.0.2) {
  exclude module: 'threetenbp'
}

Or set transitive to false:

compile('org.aaronhe:threetenbp-gson-adapter:1.0.2') {
  transitive = false
}

License

Copyright (C) 2015 Aaron He

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.0.2
1.0.1
1.0.0