I am new to Android and I am currently facing an issue to get current time given the timezone.
I get timezone in the format \"GMT-7\" i.e. string. and I have the sys
One way to deal with time zone and milliseconds values:
val currentDateTime = Calendar.getInstance().apply {
timeZone?.let {
val tzCalendar = Calendar.getInstance(it)
this.set(Calendar.HOUR_OF_DAY, tzCalendar.get(Calendar.HOUR_OF_DAY))
this.set(Calendar.MINUTE, tzCalendar.get(Calendar.MINUTE))
}
}.time
This way you're getting time in milliseconds for the specific timezone.