How to find if a date-time is in given time slot in Groovy? | < One Byte at a Time />
public Boolean nowBetween(String beg, String end, String format = "HH:mm") {
def timeBeg = new SimpleDateFormat(format).parse(beg);
def timeEnd = new SimpleDateFormat(format).parse(end);
def timeRange = timeBeg..timeEnd;
def timeNow = new SimpleDateFormat(format).format(new Date());
def time = new SimpleDateFormat(format).parse(timeNow);
return timeRange.containsWithinBounds(time);
}
K4NZ / 处理日期时间
Groovy - Dates & Times - Tutorialspoint
DateTimeExtensions (Groovy 3.0.6)
# 2020-10-02 #「Apache Groovy」- 处理日期时间
原文:https://www.cnblogs.com/k4nz/p/13761651.html