Use a Calendar to get the values of different time fields:
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timeInMillis);
int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
int monthOfYear = cal.get(Calendar.MONTH);
This function will give you a String date from milliseconds
public static String getFormattedDateFromTimestamp(long timestampInMilliSeconds)
{
Date date = new Date();
date.setTime(timestampInMilliSeconds);
String formattedDate=new SimpleDateFormat("MMM d, yyyy").format(date);
return formattedDate;
}
you can use like this
Use a Calendar to get the values of different time fields:
Convert the
milliseconds
toDate
instance and pass it to the chosen formatter:This function will give you a String date from milliseconds
You could convert the milliseconds to a date object and then extract date in the format of a time string and another string of just the date