从UNIX时间戳转换为“今天在:currentTime”使用Java

问题描述:

我尝试将UNIX时间戳转换为今天的日期时间。

I've tried to convert a UNIX Timestamp to todays date time.

就像我有一个简单的UNIX时间戳,然后我想像这样转换它:

Like I have a simple UNIX Timestamp and then I want to convert it like this:

今日时间:theTimeFromMyTimestamp

任何有正确解决方案的人?

Anyone that has a correct solution for this?

提前致谢!

试试这个 DateFormat.getDateFormat(mContext).format(new Date(myTimestamp * 1000))

As new Date( )需要毫秒而不是秒,你需要乘以1000倍

As new Date() requires milliseconds instead of seconds, you have to multiple by 1000