caipivara
5/20/2016 - 12:16 AM

Android / Kotlin - format to UTC using this formatter from date data. "yyyy-MM-dd'T'HH:mm:ss'Z'"

Android / Kotlin - format to UTC using this formatter from date data. "yyyy-MM-dd'T'HH:mm:ss'Z'"

fun SimpleDateFormat.format(year: Int, month: Int, day: Int, hour: Int, minute: Int): String {
  timeZone = TimeZone.getTimeZone("UTC")

  val calendar = GregorianCalendar.getInstance()
  calendar.clear()
  calendar.set(year, month, day, hour, minute)

  return format(calendar.time)
}