Skip to content

Instantly share code, notes, and snippets.

@lifeparticle
Created October 22, 2015 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifeparticle/0054b02c7d71b53fd484 to your computer and use it in GitHub Desktop.
Save lifeparticle/0054b02c7d71b53fd484 to your computer and use it in GitHub Desktop.
Convert Date
/**
* 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