Dmitry Khalanskiy [JB]
02/29/2024, 12:48 PMJohn O'Reilly
02/29/2024, 1:13 PMprivate fun getSessionTime(session: SessionDetails, timeZone: TimeZone): String {
val dateTimeFormat = LocalDateTime.Format {
byUnicodePattern("HH:mm")
}
return session.startsAt.format(dateTimeFormat)
//return dateService.format(session.startsAt, timeZone, "HH:mm")
}
just to confirm, there isn't way right now to use timeZone?Dmitry Khalanskiy [JB]
02/29/2024, 1:15 PMJohn O'Reilly
02/29/2024, 1:18 PMJohn O'Reilly
02/29/2024, 4:34 PMMMM
format doesn't work....this is due to the "locale-invariant" part?Dmitry Khalanskiy [JB]
03/01/2024, 9:48 AMmonthName(MonthNames.ENGLISH_ABBREVIATED)
.John O'Reilly
03/01/2024, 10:08 AMDmitry Khalanskiy [JB]
03/01/2024, 10:12 AMLocalDateTime.Format {
dayOfMonth()
char(' ')
monthName(MonthNames.ENGLISH_ABBREVIATED)
}
Here's the README about defining custom formats: https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#working-with-other-string-formats Using Java pattern strings is discouraged.John O'Reilly
03/01/2024, 10:27 AMJohn O'Reilly
03/01/2024, 10:30 AMchar
or is there some other way of doing that?
val confDateFormat = LocalDateTime.Format {
dayOfMonth()
char(' ')
monthName(MonthNames.ENGLISH_ABBREVIATED)
char(',')
year()
}
Dmitry Khalanskiy [JB]
03/01/2024, 10:31 AMchars(", ")
John O'Reilly
03/01/2024, 11:28 AMflorent
03/01/2024, 1:46 PMDmitry Khalanskiy [JB]
03/01/2024, 1:55 PMval string = "2023-11-26T23:22:06.428362Z[Europe/London]"
val format = DateTimeComponents.Format {
dateTimeComponents(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET)
char('[')
timeZoneId()
char(']')
}
format.parse(string).apply {
check(toLocalDateTime() == LocalDateTime(2023, 11, 26, 23, 22, 6, 428362000))
check(toUtcOffset() == UtcOffset.ZERO)
check(timeZoneId == "Europe/London")
check(toInstantUsingOffset() == LocalDateTime(2023, 11, 26, 23, 22, 6, 428362000).toInstant(UtcOffset.ZERO))
}
florent
03/01/2024, 1:58 PMDmitry Khalanskiy [JB]
03/01/2024, 2:01 PMDateTimeComponents
in https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#parsing-and-formatting-partial-compound-or-out-of-bounds-data. Is it missing something?florent
03/01/2024, 2:03 PMtimeZoneId()
Dmitry Khalanskiy [JB]
03/01/2024, 2:06 PMJoel Denke
03/01/2024, 5:43 PMDmitry Khalanskiy [JB]
03/02/2024, 9:41 AM