加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 这是liftweb TimeHelpers的一个错误:60.分钟不等于1.h

发布时间:2020-12-16 08:47:56 所属栏目:安全 来源:网络整理
导读:scala import net.liftweb.util.TimeHelpers._import net.liftweb.util.TimeHelpers._scala 60.minutes == 1.hourres14: Boolean = falsescala 解决方法 根据David Pollak(谁应该知道),这是由于joda时间.见 Is It a bug of liftweb TimeHelpers: 60.minutes
scala> import net.liftweb.util.TimeHelpers._

import net.liftweb.util.TimeHelpers._

scala> 60.minutes  == 1.hour

res14: Boolean = false

scala>

解决方法

根据David Pollak(谁应该知道),这是由于joda时间.见 Is It a bug of liftweb TimeHelpers: 60.minutes not equals 1.hour.

解决方案是转换为Duration,然后比较这两个值.从Period.java开始:

The definition of a period also affects the equals method. A period of
1 day is not equal to a period of 24 hours,nor 1 hour equal to 60
minutes. This is because periods represent an abstracted definition of
a time period (eg. a day may not actually be 24 hours,it might be 23
or 25 at daylight savings boundary). To compare the actual duration of
two periods,convert both to durations using toDuration,an operation
that emphasises that the result may differ according to the date you
choose.

此解决方案由上述链接提供给google组线程,并在此处复制,以便其他人可以在此处找到它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读