Class JavaTimeTypeAdapters

java.lang.Object
com.google.gson.internal.bind.JavaTimeTypeAdapters
All Implemented Interfaces:
TypeAdapters.FactorySupplier

final class JavaTimeTypeAdapters extends Object implements TypeAdapters.FactorySupplier
Type adapters for java.time types.

These adapters mimic what ReflectiveTypeAdapterFactory would produce for the same types. That is by no means a natural encoding, given that many of the types have standard ISO representations. If Gson had added support for the types at the same time they appeared (in Java 8, released in 2014), it would surely have used those representations. Unfortunately, in the intervening time, people have been using the reflective representations, and changing that would potentially be incompatible. Meanwhile, depending on the details of private fields in JDK classes is obviously fragile, and it also needs special --add-opens configuration with more recent JDK versions. So here we freeze the representation that was current with JDK 21, in a way that does not use reflection.