handlebars.kotlin-client.infrastructure.LocalDateTimeAdapter.kt.mustache Maven / Gradle / Ivy
package {{packageName}}.infrastructure
import com.squareup.moshi.FromJson
import com.squareup.moshi.ToJson
{{^threetenbp}}
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
{{/threetenbp}}
{{#threetenbp}}
import org.threeten.bp.LocalDateTime
import org.threeten.bp.format.DateTimeFormatter
{{/threetenbp}}
class LocalDateTimeAdapter {
@ToJson
fun toJson(value: LocalDateTime): String {
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value)
}
@FromJson
fun fromJson(value: String): LocalDateTime {
return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy