From year, month, date to Long
val year = 2020
val month = 3
val day = 11
val calendar = Calendar.getInstance()
calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.MONTH, month)
calendar.set(Calendar.DAY_OF_MONTH, day)
val longTYpeVariable = calendar.timeInMillis
From Long to year, month abd day
calendar.timeInMillis = longTYpeVariable
val year1 = calendar.get(Calendar.YEAR)
val month1 = calendar.get(Calendar.MONTH)
val day1 = calendar.get(Calendar.DAY_OF_MONTH)
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.