@org.testng.annotations.Test
public void fun6() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDateStr = simpleDateFormat.format(new Date());
String endTime = "2020-01-17 12:58";
LOGGER.info("startDateStr : {} ; endTime : {};", startDateStr, endTime);
LocalDateTime start = LocalDateTime.parse(startDateStr , Constant.DateTimeFormat.YYYY_MM_DD_HH_MM);
LocalDateTime end = LocalDateTime.parse("2020-01-17 12:58", Constant.DateTimeFormat.YYYY_MM_DD_HH_MM);
Duration duration = Duration.between(start, end);
long minutes = duration.toMinutes();
System.out.println(minutes);
duration.toDays();
duration.toHours();
duration.toMillis();
}
DateTimeFormatter YYYY_MM_DD_HH_MM = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
DateTimeFormatter YYYY_MM_DD_HH_MM_SS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");