Skip to content

Instantly share code, notes, and snippets.

@umpteenthdev
Created January 25, 2019 07:32
Show Gist options
  • Select an option

  • Save umpteenthdev/8622baebf557fbd1924785d529ddc103 to your computer and use it in GitHub Desktop.

Select an option

Save umpteenthdev/8622baebf557fbd1924785d529ddc103 to your computer and use it in GitHub Desktop.
How to parse ISO 8601 String to Date. SimpleDateFormat
import java.text.SimpleDateFormat
import java.util.*
fun toDate(text: String): Date {
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ")
val modifiedText = text.substring(0..25) + "GMT" + text.substring(26)
return dateFormat.parse(modifiedText)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment