我将时间标签设置为created_on =“ 1324987878”,我想将时间设置为5:41 PM。
Use SimpleDateFormat API.
Date dateObj = new Date(1324987878);
SimpleDateFormat sdfAM = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
System.out.println(sdfAM.format(dateObj));
Output:
Jan 16, 1970 01:33 PM
Use SimpleDateFormat
Sample Code
long yourmilliseconds = 1324987878;
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm +a");
Date resultdate = new Date(yourmilliseconds);
System.out.println(sdf.format(resultdate));
Use this method, it will return the time as Apr 6, 2011 5:23AM
public static String getTime(long milliseconds)
{
return DateFormat.format("MMM dd, yyyy h:mmaa", milliseconds).toString();
}
long created_on = "1324987878";
String pattern = "HH:mm a"
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
Date date = new Date(created_on);
// 5:41 PM
String yourFormatedDate = dateFormat.format(date);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.