简体   繁体   English

如何更改joda time DateTime对象的小时和分钟?

[英]How do I change the hour and minute on a joda time DateTime object?

I've tried the following two options: 我尝试了以下两个选项:

        DateTime dt = new DateTime();
        dt = dt.plusDays(1).withMinuteOfHour(0);

and

        DateTime dt = new DateTime();
        dt = dt.withMinuteOfHour(0);

they both report the following error message: 他们都报告以下错误消息:

Method "withMinuteOfHour" with signature "(I)Lorg/joda/time/DateTime;" is not applicable on this object

I'm using joda time 2.3: 我正在使用joda时间2.3:

joda-time:joda-time:2.3

You can also do this 你也可以这样做

DateTime dt = new DateTime();
dt = dt.minusMinutes(dt.minuteOfHour()).minusSecond(dt.secondOfMinute());

Tracked this to a version conflict between the joda time version included with weblogic, and the one that my application wants to use. 跟踪这与weblogic附带的joda时间版本和我的应用程序想要使用的版本之间的版本冲突。

See the answer to this question for ideas for a workaround - solutions #2/#3 in the accepted answer are probably the correct ones to use (and worked for me in this situation). 有关解决方法的建议,请参阅问题的答案 - 已接受答案中的解决方案#2 /#3可能是正确的解决方案(在这种情况下适用于我)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 给定一个DateTime对象,如何在Joda Time中获取DateTimeZone? - Given a DateTime object, how do I get DateTimeZone in Joda Time? 如何将Joda Time DateTime对象转换为SQL Server格式的String? - How do I convert a Joda Time DateTime object into a String in SQL Server format? 如何将特定日期设置为 Joda Time DateTime 对象? - How can I set a specific date into a Joda Time DateTime object? 如何将Joda DateTime对象添加到我的MSSQL数据库中 - How do i add a Joda DateTime Object into my MSSQL database 具有指定小时:分钟的Joda日期时间,但晚于现在 - Joda DateTime with specified hour:minute, but later than now 使用Joda Time减去1小时到DateTime - minus 1 hour to DateTime using Joda Time 在JDO / DataNucleus中,我可以查询Joda-Time DateTime对象吗? - In JDO/DataNucleus can I query for a Joda-Time DateTime object? 我如何判断一个joda-time DateTime对象是否在另一个jale-time内4小时内? - How can i tell if one joda-time DateTime object is within 4 hours of another? 在后端使用Joda DateTime,如何转换为JavaScript Date对象? - Using Joda DateTime on the backend, how do I convert to a JavaScript Date object? 如何修改我的@SQLUpdate将Joda DateTime对象转换为h2可读的时间戳? - How do I modify my `@SQLUpdate` to convert a `Joda` `DateTime` object into an `h2`-readable timestamp?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM