# Kotlinx-datetime is now serializable

**URL:** https://discuss.kotlinlang.org/t/kotlinx-datetime-is-now-serializable/21556
**Category:** Uncategorized
**Created:** [April 17, 2021, 2:22am UTC](https://discuss.kotlinlang.org/t/kotlinx-datetime-is-now-serializable/21556 "2021-04-17T02:22:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ideablender](https://avatars.discourse-cdn.com/v4/letter/i/c5a1d2/32.png) [@ideablender](https://discuss.kotlinlang.org/u/ideablender)
#### Post date: [April 17, 2021, 2:22am UTC](https://discuss.kotlinlang.org/t/kotlinx-datetime-is-now-serializable/21556/1 "2021-04-17T02:22:29Z")

</div>

Get the word out, this is great for MPP folks!

i implemented like this on my common side

> @Serializable  
> data class RestResponseDTO(  
> @SerialName(“payload”)  
> val payload:T,  
> @Contextual  
> val dt: LocalDateTime = testDateTime  
> )

and decoded like this on the ktor-client side:

> ```
> private fun decodeList(input:String) : RestResponseDTO<List<BookDTO>>{
> val decoded = Json.decodeFromString(RestResponseDTO.serializer(ListSerializer(BookDTO.serializer())), input)
> console.log("""
> dayOfMonth : ${decoded.dt.dayOfMonth}
> year : ${decoded.dt.year}
> hour : ${decoded.dt.hour}
> minute : ${decoded.dt.minute}
> """.trimIndent())
> console.log(decoded.dt == testDateTime)
> return decoded
> }
> suspend fun fetchAll() {
> val url = buildRestUrl(BookDTO.restStub)
> console.log(url)
> val resp = jsonClient.get<String>(urlString = buildRestUrl(BookDTO.restStub))
> val obj = decodeList(resp)
> console.log(obj)
> }
> 
> ```

there is probably a much better way to do this, but i am super happy that it is working!!!
