Hello guys, I putting my fingers in Jupyter-kotlin...
# datascience
a
Hello guys, I putting my fingers in Jupyter-kotlin, and I take fun ! But I didn’t found any way to parse Date ? Is there any lib that may help me to deal with ? I need to calculate the time between 2 dates !
r
Hello! You may have even more fun with https://github.com/Kotlin/kotlinx-datetime
a
This is not supported by Jupyter, is it ?
@roman.belov
r
Any library is supported by Kotlin Jupyter. For some of them there’re shortcuts like
%use multik
but for others you may just import jar pointing out maven coordinates directly
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime:0.3.1")
👀 1
👍 2
i
This exact library won't work with jupyter kernel: its JAR doesn't contain class files, it contains
kotlin_metadata
files instead:
Need to investigate it better.
kotlinx.serialization
works fine even being multiplatform
Well, this will work fine:
Copy code
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.3.1")
import kotlinx.datetime.*
The problem is that we use Maven resolver that takes only POM files into consideration. In this library, information about library variants is located in Gradle metadata file. Update: they even mention this in the usage instruction https://github.com/Kotlin/kotlinx-datetime#maven
a
Jupyter uses maven resolver, it does not recognize Gradle metadata. So you need to add platform prefixes for mpp.
r
Are there any plans to use a gradle resolver? Or add support for gradle metadata somehow
a
I do not think -jvm suffix worth it. It should possible to do that in the notebook itself (automatically add suffix). But it is easy to add it manually.
i
No, there are no such plans for now, we are not going to provide a full-fledged build system inside Kotlin scripts. It turned out that even supporting Maven resolver which is rather minimalistic may cause problems in its maintenance
a
By the way, in this particular case, kotlinx-datetime is not needed since it is built on top of java.time and java.time is available out of the box.
h
Coming back to the original question: You could use JDK APIs to do so https://www.baeldung.com/java-date-difference