how can I format a LocateDateTime object to a stri...
# getting-started
s
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
Tou may be more lucky asking this question in the #kotlinx-datetime channel
s
how about:
Copy code
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HH:mm:ss") // initialize only once
val dateTime: LocalDateTime = ...
val formattedDateTime = dateTime.format(formatter)
?
h
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.
☝️ 1
s
hopefully this tutorial helps.