Joda-Time 可以代替JDK日期/时间库
API 地址: https://www.joda.org/joda-time/apidocs/index.html 例如: val now = DateTime() val yesterday = DateTime("2018-11-08") log.info("当前时间:{}",now.toString("yyyy-MM-dd HH:mm:ss")) log.info("和系统时间比:{}",yesterday.isAfterNow) log.info("和其他日期比:{}",yesterday.isEqual(now)) log.info("月末日期:{}", now.dayOfMonth().withMaximumValue()) log.info("N天后的日期:{}", now.plusDays(10).toString("yyyy-MM-dd HH:mm:ss")) log.info("星期几:{}", now.dayOfWeek)
具体功能看文档
评论区