-
-
Save victorbrndls/24b83e010e8db9818cff7d4b615547f9 to your computer and use it in GitHub Desktop.
This file contains 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
val isoFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") | |
fun Date.toISOFormat() : String = isoFormatter.format(this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please be careful!. SimpleDateFormat is NOT thread safe, so re-using it to format multiple dates is not a good practice.
val isoFormatter get() = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
will give you a new instance for every call. I would suggest this instead.