I have an epoch value in milliseconds. I would like extract the date (02/11/2013) and time (09:23 am) from this separately in two strings.
could someone please help with that?
Thanks
解决方案
"I would like extract the date (02/11/2013) and time (09:23 am) from this separately in two strings."
Date date = new Date(epoch); // 'epoch' in long
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
String dateString = formatter.format(date);
formatter = new SimpleDateFormat("hh:mm a"); //The "a" is the AM/PM marker
String time = formatter.format(date);