Get the current time with Kotlin. I'm making an app that has an alarm function. This is different from Swift.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calendar = Calendar.getInstance() | |
val year = calendar.get(Calendar.YEAR) | |
val month = calendar.get(Calendar.MONTH) | |
val day = calendar.get(Calendar.DAY_OF_MONTH) | |
val hour = calendar.get(Calendar.HOUR_OF_DAY) | |
val minute = calendar.get(Calendar.MINUTE) | |
val second = calendar.get(Calendar.SECOND) | |
Log.v("time:year",year.toString()) | |
Log.v("time:month",month.toString()) | |
Log.v("time:day",day.toString()) | |
Log.v("time:hour",hour.toString()) | |
Log.v("time:minute",minute.toString()) | |
Log.v("time:second",second.toString()) |