LocalDateTime.parse 转化需要现将原有的String时间格式校对好,才能转化为LocalDateTime
public static void main(String[] args) {
String gpsTime= "2022-03-19 17:37:38";
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
System.out.println(LocalDateTime.parse(gpsTime,df));
long minutes= ChronoUnit.MINUTES.between(LocalDateTime.parse(gpsTime, df),LocalDateTime.now());
System.out.println(minutes);
}