android - 将毫秒字符串转换为日期字符串

标签 android date

<分区>

Possible Duplicate:
how to convert milliseconds to date format in android?

我有一个毫秒字符串,想将其转换为日期字符串。

像这样:

毫秒:1345032624325E12 -> 日期:2012 年 8 月 15 日星期三 14:10:24

我该怎么做?

最佳答案

希望对你有帮助 how to convert milliseconds to date format in android?

 private String getDate(long milliSeconds, String dateFormat)
    {
        // Create a DateFormatter object for displaying date in specified format.
        DateFormat formatter = new SimpleDateFormat(dateFormat);

        // Create a calendar object that will convert the date and time value in milliseconds to date. 
         Calendar calendar = Calendar.getInstance();
         calendar.setTimeInMillis(milliSeconds);
         return formatter.format(calendar.getTime());
    }

关于android - 将毫秒字符串转换为日期字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11969383/

相关文章:

iphone - 我想将我的 HTML 网站转换成 iPhone 或 Droid 兼容网站。我怎样才能做到这一点?

mysql - 尝试解决MySQL选择查询中的日期条件

android - ionic 3 : storage in both IndexedDB and Web SQL

android - Android应用程序可以 self 升级吗?

android - 无法通过我的 Android 应用程序访问我的 Google 电子表格

当前一周的 PHP 工作日,为什么 date() 和 strtotime 下周需要?

jquery - 在 HTML 上使用 jQuery 选择生日/出生日期格式的菜单

sql - JOIN 打破 WHERE 子查询

Mysql - 同一个表从另一列复制日期列但减少 3 天

android - GridView 行高行为不正确