获取时间戳的方法
long time1 = System.currentTimeMillis();
long time2 = Calendar.getInstance().getTimeInMillis();
long time3 = new Date().getTime();
long time4 = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
格式化时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format1 = sdf.format(new Date());
String format2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
时间格式转换
String strTime ="2021-10-22 12:14:09";
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime time = LocalDateTime.parse(strTime, dateTimeFormatter);
//字符串时间转换为时间戳
long timeM = time.toEpochSecond(ZoneOffset.of("+8"));



