📜  如何在 kotlin 中获取当前日期 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:18.232000             🧑  作者: Mango

代码示例1
import java.time.LocalDateTime
import java.time.temporal.ChronoField;  

fun main() {
    
    val current = LocalDateTime.now()
    println(current) // 2021-12-24T13:15:28.602
    
    println("Today is: \n ${current.get(ChronoField.DAY_OF_MONTH)} \n Month: ${current.get(ChronoField.MONTH_OF_YEAR)} \n Year: ${current.get(ChronoField.YEAR)}")
    
  /*
   Today is: 24 
   Month: 12 
   Year: 2021
   
    */
    
}