/**
* 获取到毫秒级时间戳
* @param localDateTime 具体时间
* @return long 毫秒级时间戳
*/
public static long toEpochMilli(LocalDateTime localDateTime){
return localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
}
/**
* 毫秒级时间戳转 LocalDateTime
* @param epochMilli 毫秒级时间戳
* @return LocalDateTime
*/
public static LocalDateTime ofEpochMilli(long epochMilli){
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneOffset.of("+8"));
}
/**
* 获取到秒级时间戳
* @param localDateTime 具体时间
* @return long 秒级时间戳
*/
public static long toEpochSecond(LocalDateTime localDateTime){
return localDateTime.toEpochSecond(ZoneOffset.of("+8"));
}
/**
* 秒级时间戳转 LocalDateTime
* @param epochSecond 秒级时间戳
* @return LocalDateTime
*/
public static LocalDateTime ofEpochSecond(long epochSecond){
return LocalDateTime.ofEpochSecond(epochSecond, 0,ZoneOffset.of("+8"));
}