Saq*_*asi 10 datetime android android-date
我有时间milliseconds,现在我想与这些分开 .timedatemilliseconds
我怎样才能做到这一点???
Moh*_*eem 24
你可以这样使用
Calendar cl = Calendar.getInstance();
cl.setTimeInMillis(milliseconds); //here your time in miliseconds
String date = "" + cl.get(Calendar.DAY_OF_MONTH) + ":" + cl.get(Calendar.MONTH) + ":" + cl.get(Calendar.YEAR);
String time = "" + cl.get(Calendar.HOUR_OF_DAY) + ":" + cl.get(Calendar.MINUTE) + ":" + cl.get(Calendar.SECOND);
Run Code Online (Sandbox Code Playgroud)
Kir*_*mar 19
此函数将为您提供从毫秒开始的字符串日期
public static String getFormattedDateFromTimestamp(long timestampInMilliSeconds)
{
Date date = new Date();
date.setTime(timestampInMilliSeconds);
String formattedDate=new SimpleDateFormat("MMM d, yyyy").format(date);
return formattedDate;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21072 次 |
| 最近记录: |