Convert time in long to specific date format – SimpleDateFormat in action!

Here is that pretty snippet for converting long to specific date format:

[java]public static String getDate(long milliSeconds, String dateFormat)
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
return formatter.format(calendar.getTime());

I took source from:

Read more