Hello all! I’m using kotlinx-datetime in a project...
# kotlinx-datetime
c
Hello all! I’m using kotlinx-datetime in a project, and I’ve noticed something odd here in my side. I’m converting a
Calendar
object to
LocalDateTime
(kotlinx) by setting the
year
,
month
, etc. on the constructor; and I’ve noticed that when I call
.toString
it prints something like 2021-03-27T09:00 instead of 2021-03-27T090000Z. What I might be doing wrong?
j
local datetime doesn't have a zone.
1
c
According to documentation:
The library is based on the ISO 8601 international standard, other ways to represent dates and times are out of its scope. Internationalization (such as locale-specific month and day names) is out the scope, too.
And if I’m not mistaken this ISO 8601 guarantees timezone no?
i
No, there are different representations of date/time entities in ISO, some of them include offset, some do not.
LocalDateTime
corresponds to the representation that does not include offset. Perhaps
Instant
type is what you're looking for.
c
Understood, thanks you 🙂