@ApiOperation("时间加减操作")
private Date getChangeTime(Date nowTime,Long changevalue)
{
//nowTime=基础时间,将在此时间上做加减
//changevalue=时间变换量,如changevalue=60,则获取[基础时间]60秒后的时间
//如 changevalue=-60 ,则获取[基础时间]60秒前的时间
Date newTime =new Date(nowTime.getTime()+ 1000L * changevalue);
return newTime;
}
//如:获取当前时间100秒以后的时间:
Date nowDate = new Date(); //获取当前时间
Date newDate = getChangeTime(nowDate,100L);
@ApiOperation("时间Date转LocalDateTime")
private LocalDateTime DateToLocalDateTime(Date locTime)
{
String firstString= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locTime);
LocalDateTime firstTime = LocalDateTime.parse(firstString, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
return firstTime;
}