Class Rfc3339DateJsonAdapter

java.lang.Object
com.squareup.moshi.JsonAdapter<Date>
com.squareup.moshi.adapters.Rfc3339DateJsonAdapter

public final class Rfc3339DateJsonAdapter extends com.squareup.moshi.JsonAdapter<Date>
Formats dates using RFC 3339, which is formatted like 2015-09-26T18:23:50.250Z. This adapter is null-safe. To use, add this as an adapter for Date.class on your Moshi.Builder:

 Moshi moshi = new Moshi.Builder()
     .add(Date.class, new Rfc3339DateJsonAdapter())
     .build();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.squareup.moshi.JsonAdapter

    com.squareup.moshi.JsonAdapter.Factory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    fromJson(com.squareup.moshi.JsonReader reader)
     
    void
    toJson(com.squareup.moshi.JsonWriter writer, Date value)
     

    Methods inherited from class com.squareup.moshi.JsonAdapter

    failOnUnknown, fromJson, fromJson, fromJsonValue, indent, lenient, nonNull, nullSafe, serializeNulls, toJson, toJson, toJsonValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Rfc3339DateJsonAdapter

      public Rfc3339DateJsonAdapter()
  • Method Details

    • fromJson

      public Date fromJson(com.squareup.moshi.JsonReader reader) throws IOException
      Specified by:
      fromJson in class com.squareup.moshi.JsonAdapter<Date>
      Throws:
      IOException
    • toJson

      public void toJson(com.squareup.moshi.JsonWriter writer, Date value) throws IOException
      Specified by:
      toJson in class com.squareup.moshi.JsonAdapter<Date>
      Throws:
      IOException