我如何用Java转换这个日期? [英] How can I convert this date in Java?

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

问题描述

我想转换:

2010-03-15T16:34:46Z

转换为5小时前的内容

我如何在Java ?

推荐答案

JodaTime 支持从用户定义的格式进行解析。参见DateTimeFormatterBuilder和DateTimeBuilder.parseDateTime()。

JodaTime supports parsing from a user-defined format. See DateTimeFormatterBuilder and DateTimeBuilder.parseDateTime().

一旦你有一个DateTime,你可以创建一个持续时间或期间从那个和当前的时间,并使用另一个格式化到漂亮-打印。 [参见上面评论中BalusC引用的PeriodFormatter示例。]

Once you have a DateTime, you can create a Duration or Period from that and the current time, and use another formatter to pretty-print. [See the PeriodFormatter example referenced by BalusC in comments above.]

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

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