日期格式转换val startAt = LocalDate.parse("2017-02-01").atStartOfDay().toInstant(ZoneOffset.UTC)val endAt = LocalDate.parse("2017-02-03").atStartOfDay().toInstant(ZoneOffset.UTC)
var simpleDateFormat:SimpleDateFormat = new SimpleDateFormat("yyyy/MM/dd")var dateToExcelStartAt = simpleDateFormat.format(Date.from(LocalDateTime.ofInstant(startAt,ZoneId.systemDefault()).atZone(ZoneId.systemDefault()).toInstant))var dateToExcelEndAt = simpleDateFormat.format(Date.from(LocalDateTime.ofInstant(endAt,ZoneId.systemDefault()).atZone(ZoneId.systemDefault()).toInstant))
def getEndTime(startAt: Instant, seconds: Long): Instant = { // 取得未来几天后的日期 startAt是开始时间,类型为Instant ,seconds为天数的毫秒数 startAt.plusSeconds(seconds)}def getStartTime(seconds: Long): Timestamp = {// 取得当前时间过去几天前的日期 seconds为天数的毫秒数 Instant.now.minusSeconds(seconds).toTimestampLegacy}
//传入时间字符串类型为"
2016-01-01T00:00:00Z
"def getSearchStartAt(implicit request: RequestHeader): Timestamp = { request.getQueryString("startAt").map(date => Timestamp.from(Instant.parse(date))).getOrElse(Timestamp.from(Instant.parse("2016-01-01T00:00:00Z")))}
//传入类型为毫秒数
def getSearchEndAt(implicit request: RequestHeader): Timestamp = { request.getQueryString("endAt").map(date => Timestamp.from(Instant.ofEpochSecond(date.toLong))).getOrElse(Timestamp.from(Instant.now))}