val items = TimeZone.getAvailableIDs().map { id -> // val timeZone = TimeZone.getTimeZone(id) // val name = timeZone.displayName val zone = ZoneId.of(id); val offsetToday = OffsetDateTime.now(zone).offset val offset = offsetFormatter.format(offsetToday) // GMT val tokens = id.replace("_", " ").split("/") val name = if (tokens.size == 2) { val (country, city) = tokens "$city ($country)" } else id TimezoneView(id, name = name, offsetName = offset, offset = offsetToday.totalSeconds)}
class TimezoneView(val id: String, val name: String, val offsetName: String, offset: Int)
Sample
Kuala Lumpur (Malaysia) // name
GMT+8:00 // offsetName
New York (United States) // name
GMT-4:00 // offsetName