小编Est*_*dão的帖子

Joda时间 - 将UTC日期时间转换为日期 - 使用Joda的1.2.1.1版本

大家,早安.

我想帮助您了解如何使用1.2.1.1版本的Joda Time完成org.joda.time.DateTime到java.util.Date的转换.

为何选择Joda 1.2.1.1?因为目前我只能使用这个版本的Joda"不幸".

我的测试>

    System.out.println("JODA Version : 2.8.2 - UTC TIME to Date " + new DateTime().withZone(DateTimeZone.UTC).toLocalDateTime().toDate());;
    System.out.println("JODA Version : 1.2.1.1 - UTC TIME to Date " + new DateTime().withZone(DateTimeZone.UTC).toDate());;


JODA Version : 2.8.2 - UTC TIME to Date Fri Sep 18 17:34:36 BRT 2015
JODA Version : 1.2.1.1 - UTC TIME to Date Fri Sep 18 14:34:36 BRT 2015
Run Code Online (Sandbox Code Playgroud)

我的问题是在版本1.2.1.1中,日期在我的本地设置上,在这个版本中没有toLocalDateTime()方法.

我会请求您的帮助和经验,以便在JODA版本:1.2.1.1中发现执行此转换的最佳实践

如何执行此转换为小时:分钟:UTC这个旧版JODA的第二个?

我研究了很多,看到一些人这样说会是一个好习惯吗?

public  static Date converterDateTimeToUTCDate(final DateTime dateTime) throws ParseException {
    DateTime dat = dateTime.withZone(DateTimeZone.UTC);
    return …
Run Code Online (Sandbox Code Playgroud)

java datetime utc jodatime

0
推荐指数
1
解决办法
4711
查看次数

标签 统计

datetime ×1

java ×1

jodatime ×1

utc ×1