Hi, guys! I'm entirely new to the kotlin (by exten...
# ktor
m
Hi, guys! I'm entirely new to the kotlin (by extension, ktor) ecosystem and I'm building the server-side logic for an existing client application. Using exposed ORM, I'm trying to use a datetime field but when I use the datetime function, it keeps throwing
unresolved reference: datetime
. I've also added the exposed-java-time to my dependencies.
h
Could it be that you also need the kotlinx-datetime dependency? (https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-datetime/0.4.0/versions)
m
I've also tried this but same error. Here's what my dependencies list looks like
h
I see you're using Idea, so try File->Invalidate caches. Otherwise, I'm out of suggestions, I'm afraid ...
e
you shouldn't need kotlinx-datetime. But you would have to reload gradle (little icon hovering with the elephant in your editor)
h
Yes, or alt+shift+O
m
alt+shift+O doesn't work for me. I use a Linux
h
Sorry, that's CTRL+shitf+O. My bad.
m
Still doesn't work
I've invalidated my caches severally. But the error keeps returning
h
What do the imports and uses look like in the file where this error occurs?
m
Screenshot_2023-03-03_12-52-44.jpg
h
Try importing
kotlinx.datetime.Instant
and replace your call to datetime with something like
Instant.fromEpochMilliseconds(time()).toLocalDateTime(timezone)
e
Are you trying to use DateTime from kotlinx-datetime or java.time?
m
How do I use both?
@hallvard now it shows
unresolved reference: timezone
e
you shouldn't use both.. Either you're dealing with a multiplatform project and should use kotlinx-datetime, or you're dealing with a JVM project and should use either (though I would prefer java.time since it's stable and interoperable with other libraries on the JVM)
h
You were missing an import, I think. Disregard my suggestion, follow Emil's advice, but do remember to import the stuff you use.
e
And you should use the exposed dependency for the time-handling lib you choose. so either
exposed-java-time
or
exposed-kotlin-datetime
IF you end up using exposed-java-time, this import should do the trick:
Copy code
import org.jetbrains.exposed.sql.javatime.datetime
โœ… 1
m
Thank you very much. It works now
Thanks guys for the assistance
๐Ÿ‘ 1
I was wondering if there's a reference documentation I could use to find certain import statements I can't recall by heart.
h
Won't Idea mostly suggest them for you? If you mouseover or something?
m
For the datetime problem, and some others, It didn't
e
It should have.. Could be a problem with the IntelliJ cache as @hallvard suggested earlier ๐Ÿ™‚
m
I see.. so frequent cleanings then.
e
It should not happen regularly. ๐Ÿ™‚
m
I see.. ok then
This is unrelated, but didn't think to create a new thread. I was wondering what password hashers are available in ktor? I've tried ktor-features and jbcrypt but none seems to work for me @hallvard @Emil Kantis
e
I have no idea ๐Ÿ˜ž
๐Ÿ™Œ 1
h
Sorry, I am just as ignorant as you are on this.
๐Ÿ‘ 1