Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
显然我可以创建一个Calendar带有日期的对象并get(DAY)在其上使用,但是知道 Groovy,我猜有一种更简单、更快捷的方法我只是不知道?
Calendar
get(DAY)
回答
(date1..date2).size() == 1 // true if two dates are on same calendar day
快速打开 Groovy In Action 书,发现以下示例应该有所帮助:
def today = new Date() def yesterday = today-1 assert (yesterday..today).size() == 2
比当前的最佳答案更短且更具可读性:
date1 - date2 == 0 //true if two dates are on same calendar day