Posts

Showing posts from May, 2020

android kotlin current date example

In this An article today learn get current date android for using kotlin language to follow the code:   val current = LocalDateTime.now()           val formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy. HH:mm:ss")           label_date.text = current.format(formatter)   Follow the code for  android kotlin current date example: 1.MainActivity.kt: import java.time.LocalDateTime import java.time.format.DateTimeFormatter class MainActivity: AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         val current = LocalDateTime.now()         val formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy. HH:mm:ss")         label_date.text = current.format(formatter)     }  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {         val current = LocalDateTime.now()         val formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy. HH:mm:s