如何将seconds_since_the_beginning_of_this_epoch转换为java的日期格式? [英] how to convert seconds_since_the_beginning_of_this_epoch to date format in java..?

查看:140
本文介绍了如何将seconds_since_the_beginning_of_this_epoch转换为java的日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在java ..中转换seconds_since_the_beginning_of_this_epoch( ssboetod )到日期格式?

How to convert seconds_since_the_beginning_of_this_epoch (ssboetod) to date format in java..?

例如:

我将使用 ssboetod 格式的号码:


987777000

987777000

我希望它的日期格式正常:

And I want it to be in normal date format:


Fri Apr 20 20:00 :00 2001。

Fri Apr 20 20:00:00 2001.


推荐答案

如果通过这个时代你的意思是正常的unix纪元,你可以乘以1000:

If by "this epoch" you mean the normal unix epoch, you can just multiply by 1000:

Date dt = new Date(987777000000L);

自Unix纪元以来,Java日期以毫秒衡量。

Java dates are measured in milliseconds since the Unix epoch.

尽管如此,我强烈建议您使用 Joda时间查看而不是内置的Java日期/时间API ... Joda时间是更好的。 (您仍然可以使用相同的值来构造一个 Instant 。)

As ever though, I would strongly recommend that you look at using Joda Time instead of the built-in Java date/time APIs... Joda Time is much nicer. (You'd still use the same value to construct an Instant though.)

这篇关于如何将seconds_since_the_beginning_of_this_epoch转换为java的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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