[英]what is the correct way to set a Date() object based on user input in Javascript
[英]What is the correct way to check if an instant is on a specific date
我有一个称为A的事件,它发生在自该时期(1970年1月1日)起存储的秒数(毫秒)内的瞬间(时间戳,数据时间)。 我想查找与事件A发生在同一日期的其他事件。什么是代表目标日期的最佳方法,然后有效地检查每个传入事件的目标日期。
我有一个称为A的事件,它发生在自该时期(1970年1月1日)起存储的秒数(毫秒)内的瞬间(时间戳,数据时间)。
您还不清楚要使用哪种类型来表示瞬间,因此我假设它是一个Long
代表自1970年1月1日以来的毫isecods数量。
Long event = getEventInstant()
Date targetDate = getTargetDate().clearTime()
if (new Date(event).clearTime() == targetDate) {
println "they're on the same day"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.