diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-04-18 23:10:29 -0500 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-04-18 23:10:29 -0500 |
commit | 65bf515eb2cb95a0e13cf71788e60bf6b16f5fcd (patch) | |
tree | dcc65a1f090f5afa93e6bc7c6e6c178dc10eaae2 /shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt | |
parent | 591eb35abf77aa23e5b897c92eb9ff588a968f16 (diff) | |
parent | fc3e2a6e316cb8acd6aac0553c92f9dbc6b669b4 (diff) | |
download | etbsa-trackermap-mobile-65bf515eb2cb95a0e13cf71788e60bf6b16f5fcd.tar.gz etbsa-trackermap-mobile-65bf515eb2cb95a0e13cf71788e60bf6b16f5fcd.tar.bz2 etbsa-trackermap-mobile-65bf515eb2cb95a0e13cf71788e60bf6b16f5fcd.zip |
Merge branch 'main' of lraspi:/secret/git/repos/etbsa-trackermap-mobile
Diffstat (limited to 'shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt')
-rw-r--r-- | shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt b/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt new file mode 100644 index 0000000..35f1ac6 --- /dev/null +++ b/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/utils/DateUtils.kt @@ -0,0 +1,23 @@ +package mx.trackermap.TrackerMap.utils + +import android.os.Build +import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.toJavaLocalDateTime +import java.text.SimpleDateFormat +import java.time.format.DateTimeFormatter +import java.util.* + +actual class DateUtils { + actual companion object { + actual fun formatDate(date: LocalDateTime): String { + val javaDate = date.toJavaLocalDateTime() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") + return javaDate.format(formatter) + } else { + val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) + return formatter.format(date) + } + } + } +}
\ No newline at end of file |