java 如何创建截断到最后一小时的新 Joda DateTime?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1207957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I create a new Joda DateTime truncated to the last hour?
提问by WolfmanDragon
I am pulling timestamps from a file that I want to create a new DateTime for, but I want to create the DateTime at the floor of the hour (or any Joda Period will do).
How Can I do this?
我正在从要为其创建新 DateTime 的文件中提取时间戳,但我想在整点(或任何 Joda Period 都可以)创建 DateTime。
我怎样才能做到这一点?
回答by WolfmanDragon
Wohoo, found it. Simple like everything in Joda once I traced down the calls.
哇,找到了。一旦我追踪到电话,就像 Joda 中的一切一样简单。
DateTime dt = new DateTime().hourOfDay().roundFloorCopy();

