Package de.xima.fc.helper
Class GsonJavaTimeAdapter
java.lang.Object
de.xima.fc.helper.GsonJavaTimeAdapter
A collection of
TypeAdapters for java.time.* classes.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classType adapter forDuration.static classType adapter forLocalDate.static classType adapter forLocalDate.static classType adapter forLocalDateTime.static classType adapter forLocalTime.static classType adapter forMonthDay.static classType adapter forOffsetDateTime.static classType adapter forOffsetTime.static classType adapter forPeriod.static classType adapter forYear.static classType adapter forYearMonth.static classType adapter forZonedDateTime.static classType adapter forZoneIdand 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 voidregisterAll(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.
-