I want to create an instance of `kotlinx.datetime....
# kotlinx-datetime
d
I want to create an instance of
kotlinx.datetime.format.DateTimeFormat
which will correctly parse "an iCalendar format DATE-TIME value in UTC". For example
19000101T000000Z
. ChatGPT and Github Copilot are eager to tell me how to do it with Java, but completely lost with Kotlinx datetime.
Ah, just saw this in the readme:
Copy code
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.
Looks like maybe its not possible to do directly.
d
Ah, that might be what I'm looking for!
d
If ChatGPT gives you a Java.Time pattern, you can use the trick described in https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#using-unicode-format-strings-like-yyyy-mm-dd to learn what the corresponding kotlinx-datetime code looks like.
d
I tend to rely on source level documentation, and the docs in this case didn’t link me to the examples. Now that I know where I can read about the format dsl, I’ll be able to use it more effectively;-)
d
Sorry, could you explain this in more detail? Where did you look, and where didn't you find a pointer that should have been there? We try to make the documentation comprehensive, so if there is a hole somewhere, we'd like to fix it.
d
The KDoc for
.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-datetime/0.6.1/23276007dcfffad437d5302c44e2e82c679c5c69/kotlinx-datetime-0.6.1-sources.jar!/commonMain/Instant.kt:383
. It has a "samples", but IntelliJ just shows that as "// Unresolved"
image.png
d
Yes, showing samples in the IDE is not supported. The samples are used in the reference documentation (https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-instant/-companion/parse.html)
nod 1
d
It would have benefited me to have a link to the format builder entry point.