Class GsonJavaTimeAdapter


  • public class GsonJavaTimeAdapter
    extends Object
    A collection of TypeAdapters for java.time.* classes.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • forType

        public static <T> Optional<com.google.gson.TypeAdapter<T>> forType​(Class<T> type)
        Returns the type adapter for a java.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 a java.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 a java.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 a java.time.* class).
      • registerAll

        public static void registerAll​(com.google.gson.GsonBuilder builder)
        Registers all supported type adapters for java.time.* with the given builder.
        Parameters:
        builder - Builder with which to register.