Last active
July 15, 2017 18:29
-
-
Save Tarelochkin/1a0805baa3b0f271f21c19cc7debe5c8 to your computer and use it in GitHub Desktop.
Format date with a pattern: 2017-04-12T05:41:46Z for Medium UK locale
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
String dateString = "2017-04-12T05:41:46Z" | |
SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'"); | |
Date convertedDate; | |
String formattedDate = ""; | |
try { | |
convertedDate = sourceFormat.parse(dateString); | |
//will return "12 Apr 2017" | |
formattedDate = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.UK).format(convertedDate); | |
} catch (ParseException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment