All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.com.bselzer.ktx.datetime.format.BaseDateTimeFormatter.kt Maven / Gradle / Ivy

The newest version!
package com.bselzer.ktx.datetime.format

import kotlinx.datetime.Instant
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toJavaLocalDateTime
import kotlinx.datetime.toLocalDateTime

abstract class BaseDateTimeFormatter : DateTimeFormatter {
    protected abstract val formatter: java.time.format.DateTimeFormatter

    override fun format(instant: Instant): String {
        val localDate = instant.toLocalDateTime(TimeZone.currentSystemDefault()).toJavaLocalDateTime()
        return formatter.format(localDate)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy