(1)获取当前时间前两个小时的时间
LocalDateTime now = LocalDateTime.now();
LocalDateTime oneHourAgo = now.minusHours(2);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String two_hour_ago = oneHourAgo.format(formatter);
(2)前后时间计算(ms)
long l = System.currentTimeMillis();
long l2 = System.currentTimeMillis();
l2 -l ms