title: How to convert JSON 2019-04-28T00:00:00 format to GregorianCalender in Android using Kotlin and Moshi
body: <p>I have an Android App written in Kotlin, that gets data from JSON. I use Retrofit and Moshi to retrieve the data. I receive errors because Moshi does not know how to convert a date to GregorianCalendar. How can I convert the JSON date format to the GregorianCalendar format?</p>
  
  <p>The JSON date is in the following format: 2000-06-28T00:00:00</p>
  
  <p>The API configuration:</p>
  
  <pre><code>class ApiClient {
  
      companion object {
  
          private const val BASE_URL = "http://10.0.2.2:3000"
  
          fun getClient(): Retrofit {
              val okHttpClient = OkHttpClient.Builder().build()
              val moshi = Moshi.Builder().build()
  
              return Builder().client(okHttpClient).baseUrl(BASE_URL)
                  .addConverterFactory(MoshiConverterFactory.create(moshi))
                  .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                  .build()
          }
      }
  }
  </code></pre>
  
  <p>Example class:</p>
  
  <pre><code>data class Person (
    @Json(name = "personId")
    val personId: Int,
  
    @Json(name = "personName")
    val name: String,
  
    @Json(name = "personAge")
    val age: Int,
  
    @Json(name = "isFemale")
    val isFemale: Boolean,
  
    @Json(name = "birthDate")
    val birthDate: GregorianCalendar
  
  )
  </code></pre>
  
  <pre><code>{
    "persons": [{
        "personId": 1,
        "personName": "Bert",
        "personAge": 19,
        "isFemale": "false",
        "birthDate": "2000-06-28T00:00:00"
      }
    ]
  }
  </code></pre>
  
  <p>I want the JSON date 2000-06-28T00:00:00 to be converted to GregorianCalendar or any other Date format that is not depricated but supported by minimum API21</p>