Package de.xima.fc.helper
Class GsonJavaTimeAdapter
java.lang.Object
de.xima.fc.helper.GsonJavaTimeAdapter
A collection of
TypeAdapter
s for java.time.*
classes.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Type adapter forDuration
.static class
Type adapter forLocalDate
.static class
Type adapter forLocalDate
.static class
Type adapter forLocalDateTime
.static class
Type adapter forLocalTime
.static class
Type adapter forMonthDay
.static class
Type adapter forOffsetDateTime
.static class
Type adapter forOffsetTime
.static class
Type adapter forPeriod
.static class
Type adapter forYear
.static class
Type adapter forYearMonth
.static class
Type adapter forZonedDateTime
.static class
Type adapter forZoneId
and its subclasses. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<com.google.gson.TypeAdapter<T>>
forType
(com.google.gson.reflect.TypeToken<T> type) Returns the type adapter for ajava.time.*
class.static <T> Optional<com.google.gson.TypeAdapter<T>>
Returns the type adapter for ajava.time.*
class.static void
registerAll
(com.google.gson.GsonBuilder builder) Registers all supported type adapters forjava.time.*
with the given builder.
-
Method Details
-
forType
Returns the type adapter for ajava.time.*
class.- Type Parameters:
T
- Type for which to return the adapter.- Parameters:
type
- Type for which to return the adapter.- Returns:
- The adapter for the given
java.time.*
class, or empty when the given type is not supported (or is not ajava.time.*
class).
-
forType
public static <T> Optional<com.google.gson.TypeAdapter<T>> forType(com.google.gson.reflect.TypeToken<T> type) Returns the type adapter for ajava.time.*
class.- Type Parameters:
T
- Type for which to return the adapter.- Parameters:
type
- Type for which to return the adapter.- Returns:
- The adapter for the given
java.time.*
class, or empty when the given type is not supported (or is not ajava.time.*
class).
-
registerAll
public static void registerAll(com.google.gson.GsonBuilder builder) Registers all supported type adapters forjava.time.*
with the given builder.- Parameters:
builder
- Builder with which to register.
-