java.time seems to be missing entirely. The code I'm trying it in is a simple
fun main(args: Array<String>) {
println(LocalDateTime.now())
}
Seems like I am missing something fundamental, but all I have been doing is following along in a tutorial and it just worked for the tutor.
The LocalDateTime
class has only been introduced in Java SE 8, so you need to compile your project against JDK 8 or newer.
Make sure that:
You have an installed JDK 8 or newer;
Your project is compiled against this JDK 8+.
(In IntelliJ IDEA, Ctrl / ⌘ + Shift + Alt + S → Project → Project SDK ; other build systems should be set up separately)
With the JDK configured correctly, the code should run fine as-is: (demo)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.