Created
October 22, 2015 16:45
-
-
Save lifeparticle/0054b02c7d71b53fd484 to your computer and use it in GitHub Desktop.
Convert Date
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
/** | |
* Author S Mahbub-Uz Zaman on October 23, 2015 | |
* Lisence Under GPL2 | |
*/ | |
public static String monthNames[] = {"January", "February", "March", "April", | |
"May", "June", "July", "August", "September", "October", | |
"November", "December"}; | |
// input 17/06/1991 | |
// output 17 June 1991 | |
public static String getDate(String d) { | |
try { | |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); | |
Calendar calendar = Calendar.getInstance(); | |
calendar.setTime(dateFormat.parse(d)); | |
Log.v(TAG, "Year " + calendar.get(Calendar.YEAR) + " Month " + calendar.get(Calendar.MONTH) + " Day " + calendar.get(Calendar.DAY_OF_MONTH)); | |
return calendar.get(Calendar.DAY_OF_MONTH) + " " + monthNames[calendar.get(Calendar.MONTH)] + " " + calendar.get(Calendar.YEAR); | |
} catch (ParseException e) { | |
if (MyDebug.LOG) | |
Log.v(TAG, Log.getStackTraceString(e)); | |
} | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment