Created
June 2, 2018 13:40
-
-
Save seupedro/ee9015c74d8c55fa11d5af6592df2d4f to your computer and use it in GitHub Desktop.
Formate date based on User Locale on Android
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 weddingDate = "26/02/1974"; | |
/* Specify which format is */ | |
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); | |
Date date = null; | |
try { | |
/* Parse to date object */ | |
date = sdf.parse(weddingDate); | |
} catch (ParseException e) { | |
// handle exception here ! | |
} | |
/* Format based on User Locale */ | |
java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); | |
String s = dateFormat.format(date); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment