从UNIX时间戳转换为“今天在:currentTime”使用Java [英] Convert from UNIX Timestamp to "Today at: currentTime" using Java

查看:156
本文介绍了从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

这篇关于从UNIX时间戳转换为“今天在:currentTime”使用Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆