- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
以下 2 个案例(从 2016 年 2 月 28 日/29 日到 2017 年 3 月 1 日)的 Period 结果彼此相同。
你能帮忙解释一下这种奇怪的行为吗?
案例一:2016年2月28日至2017年3月1日
Calendar start1 = Calendar.getInstance();
start1.set(2016, Calendar.FEBRUARY, 28, 0, 0, 0);
Calendar end1 = Calendar.getInstance();
end1.set(2017, Calendar.MARCH, 1, 0, 0, 0);
Interval i1 = new Interval(new DateTime(start1.getTime()), new DateTime(end1.getTime()))
System.out.println(i1.toPeriod());
结果:P1Y1D
案例2:2016年2月29日至2017年3月1日
Calendar start2 = Calendar.getInstance();
start2.set(2016, Calendar.FEBRUARY, 29, 0, 0, 0);
Calendar end2 = Calendar.getInstance();
end2.set(2017, Calendar.MARCH, 1, 0, 0, 0);
Interval i2 = new Interval(new DateTime(start2.getTime()), new DateTime(end2.getTime()))
System.out.println(i2.toPeriod());
结果:P1Y1D
最佳答案
考虑
public static void main(String[] args) throws Exception
{
LocalDate start1 = LocalDate.of(2016, Month.FEBRUARY, 28);
LocalDate start2 = LocalDate.of(2016, Month.FEBRUARY, 29);
LocalDate end = LocalDate.of(2017, Month.MARCH, 1);
Period year = Period.ofYears(1);
System.out.println(start1);
System.out.println(start2);
System.out.println(end);
System.out.println(start1.plus(year));
System.out.println(start2.plus(year));
System.out.println(start1.until(end));
System.out.println(start2.until(end));
}
输出
2016-02-28
2016-02-29
2017-03-01
2017-02-28
2017-02-28
P1Y1D
P1Y1D
这可能不是您想要的工作方式,但看起来实现是一致的。
2 月 29 日加 1 年到底是什么意思?它同样可以作为“二月的最后一天”或开始日期加上 365 天。后一个定义会导致闰年 2 月 29 日之前的几天出现问题:
February 1 2016 + 1 year == January 31 2017
February 1 2017 + 1 year == February 1 2018
这会让人们感到困惑。
这是我们日历工作方式的一个怪癖,现有的行为似乎最小化(但不是消除)行为“令人惊讶”的日期。
关于java - Joda Time : Strange behavior for leap year in Period calculation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39629657/
Leap Motion API 仅支持四种标准手势:圆圈、滑动、按键和屏幕点击。在我的应用程序中,我需要其他手势,但我不知道如何添加它们,或者是否可以添加更多手势。我阅读了 API 并没有帮助。 在我
我是一名相当新的开发人员,一直致力于使用 Leap Motion 进行处理 https://github.com/voidplus/leap-motion-processing .到目前为止,我很享受
本文整理了Java中leap.lang.yaml.YAML类的一些代码示例,展示了YAML类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项
本文整理了Java中leap.lang.yaml.YamlValue类的一些代码示例,展示了YamlValue类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等
对我来说,在制作递归方法时。我总是需要花很多时间去做,因为我会做一些测试用例,看看我的递归用例是否有效并绘制堆栈图。然而,当我问其他人时,他们只是说我需要相信自己会奏效。如果您不知道递归情况下发生了什
所以,我试图让两台计算机同时从跳跃运动中获取数据。 (使用 JavaScript API) 理想情况下,第一个会模仿第二个,在两个屏幕上显示被操纵的手 Leap.loop({host:a
我编写了一个计算闰年的程序。第二部分是如果该年不是闰年,我必须打印到下一个闰年的年数。对于 2097 年,输出显示距离下一次飞跃还有 3 年,但实际上应该是 7 年。我认为我在最后一行的代码中犯了一个
我正在尝试创建一个具有跳跃 Action 的虚拟鼓。如果一根棍子走得很快并在一瞬间改变了方向(意味着高加速度),我会把它算作“命中”。问题是我无法计算我的工具(棍子)的加速度。我完全检查了官方文档,但
我刚拿到 Leap Motion Controller 。但我必须承认,我不知道如何在 SmartMS 中启动和运行基本初始化!? 我已经包含了来自 https://github.com/logoty
本文整理了Java中ninja.leaping.configurate.yaml.YAMLConfigurationLoader类的一些代码示例,展示了YAMLConfigurationLoader类
我使用 regsubsets 来搜索模型。是否可以自动创建所有lm来自参数选择列表? library(leaps) leaps<-regsubsets(y ~ x1 + x2 + x3, data,
我们如何在 Leap Motion API 中访问点云?促使我购买它的一个功能是他们的宣传视频中的点云演示,但我似乎无法找到有关它的文档,而且论坛上的用户回复似乎参差不齐。我只是错过了什么吗? 我希望
我正在尝试在 python 中运行 Leap Motion 的基础知识。 import os, sys, inspect, thread, time 代码可以在这里看到.. http://pastie
我正在尝试将我的 Android 项目与 Leap 运动 Controller 连接,并使用 this question 中提到的过程和源代码。作为引用。 我对 Node.js 非常陌生,无法让
我注意到我从 Leap Motion Controller 获得的数据非常嘈杂。除了明显的(即手指的位置)之外,我还遇到过诸如 手指在双手之间移动, 出现“幻影”手, 手指消失并立即重新出现。 API
有没有办法从 Leap Motion 流式传输(最好使用 JS,但任何语言都可以)实际的红外摄像机视频馈送?在 0:52 here 看到的演示似乎表明该设备可以提供更多的数据,而不仅仅是点的骨架,我希
我一直在使用 Java 玩跳跃运动,它很好..但后来我尝试使用 C++,但我似乎无法让它工作。我正在使用 Visual Studio 2012 并正确设置库和包含目录。尽管如此,我总是以这个错误结束:
我刚刚开始开发 Leap 运动,我有一般性问题这是我的代码: Leap.loop(function(obj) { var hands = obj.hands.map(functi
我正在使用 Leap Motion 的 JS SDK。无论我在互联网上看到哪个示例,即使浏览器窗口位于后台,它也能正常运行=该示例在每一帧上都会更新。但是,我不知道该怎么做才能真正实现同样的目标,当浏
我正在尝试通过 OpenCV 的校准库和棋盘图案校准 Leap Moion 设备,但它没有找到棋盘角。 我使用的是印在 DIN A3 纸上的 9x6 棋盘图案,该纸又安装在一张大的白色 table 上
我是一名优秀的程序员,十分优秀!