https://kotlinlang.org logo
#ktor
Title
# ktor
m

Manasseh

03/03/2023, 11:18 AM
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

hallvard

03/03/2023, 11:22 AM
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

Manasseh

03/03/2023, 11:33 AM
I've also tried this but same error. Here's what my dependencies list looks like
h

hallvard

03/03/2023, 11:38 AM
I see you're using Idea, so try File->Invalidate caches. Otherwise, I'm out of suggestions, I'm afraid ...
e

Emil Kantis

03/03/2023, 11:40 AM
you shouldn't need kotlinx-datetime. But you would have to reload gradle (little icon hovering with the elephant in your editor)
h

hallvard

03/03/2023, 11:41 AM
Yes, or alt+shift+O
m

Manasseh

03/03/2023, 11:44 AM
alt+shift+O doesn't work for me. I use a Linux
h

hallvard

03/03/2023, 11:45 AM
Sorry, that's CTRL+shitf+O. My bad.
m

Manasseh

03/03/2023, 11:46 AM
Still doesn't work
I've invalidated my caches severally. But the error keeps returning
h

hallvard

03/03/2023, 11:51 AM
What do the imports and uses look like in the file where this error occurs?
m

Manasseh

03/03/2023, 11:53 AM
Screenshot_2023-03-03_12-52-44.jpg
h

hallvard

03/03/2023, 11:57 AM
Try importing
kotlinx.datetime.Instant
and replace your call to datetime with something like
Instant.fromEpochMilliseconds(time()).toLocalDateTime(timezone)
e

Emil Kantis

03/03/2023, 12:07 PM
Are you trying to use DateTime from kotlinx-datetime or java.time?
m

Manasseh

03/03/2023, 12:08 PM
How do I use both?
@hallvard now it shows
unresolved reference: timezone
e

Emil Kantis

03/03/2023, 12:10 PM
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

hallvard

03/03/2023, 12:10 PM
You were missing an import, I think. Disregard my suggestion, follow Emil's advice, but do remember to import the stuff you use.
e

Emil Kantis

03/03/2023, 12:11 PM
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

Manasseh

03/03/2023, 12:18 PM
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

hallvard

03/03/2023, 12:35 PM
Won't Idea mostly suggest them for you? If you mouseover or something?
m

Manasseh

03/03/2023, 12:35 PM
For the datetime problem, and some others, It didn't
e

Emil Kantis

03/03/2023, 12:40 PM
It should have.. Could be a problem with the IntelliJ cache as @hallvard suggested earlier 🙂
m

Manasseh

03/03/2023, 12:41 PM
I see.. so frequent cleanings then.
e

Emil Kantis

03/03/2023, 12:43 PM
It should not happen regularly. 🙂
m

Manasseh

03/03/2023, 1:12 PM
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

Emil Kantis

03/03/2023, 4:04 PM
I have no idea 😞
🙌 1
h

hallvard

03/03/2023, 4:44 PM
Sorry, I am just as ignorant as you are on this.
👍 1
5 Views