how can I format a LocateDateTime object to a string in format of "yyyyMMdd-HHmmss" in UTC time? -- bit shameful to ask as I have spent two hrs can not figure it out ...
x
xoangon
08/08/2023, 9:12 PM
Tou may be more lucky asking this question in the #kotlinx-datetime channel
s
Stephan Schröder
08/09/2023, 7:00 AM
how about:
Copy code
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HH:mm:ss") // initialize only once
val dateTime: LocalDateTime = ...
val formattedDateTime = dateTime.format(formatter)
?
h
hho
08/09/2023, 8:11 AM
I think the question was about the "in UTC" part … and the answer is: You can't, at least not without providing a timezone for your date first.