Created
January 25, 2019 07:32
-
-
Save umpteenthdev/8622baebf557fbd1924785d529ddc103 to your computer and use it in GitHub Desktop.
How to parse ISO 8601 String to Date. SimpleDateFormat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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