damian
02/14/2017, 8:34 PM@Throws(ParseException::class)
fun parseIso8601(input: String): Date {
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
val withZone = input.replace("Z", "+00:00")
try {
val isoDateTime = "${withZone.substring(0..22)}${withZone.substring(23)}"
return format.parse(isoDateTime)
} catch (e: IndexOutOfBoundsException) {
throw ParseException("Invalid length", 0)
}
}