//获取毫秒数 public static long strTimestamp(String str) { long time; String pattern="yyyy-MM-dd HH:mm:ss"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); LocalDateTime localDateTime=LocalDateTime.parse(str,formatter); time=localDateTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli(); return time; }
//获取秒数 public static long strTime(String str) { long time; String pattern="yyyy-MM-dd HH:mm:ss"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); LocalDateTime localDateTime=LocalDateTime.parse(str,formatter); time = localDateTime.toEpochSecond(ZoneOffset.ofHours(8)); return time; }