[英]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.