Come ottenere la data corrente nel kotlin

Esempi di codice

0
0

come ottenere la data corrente nel kotlin

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
   
    */
    
}

Pagine correlate

Pagine di esempio simili

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
English
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................