DateTimeFormatter fmTime = DateTimeFormatter.ofPattern("HH:mm");
String a = "09:20";
String b = "12:20";
String c = "23:20";
LocalTime ClockTime1 = LocalTime.parse(a,fmTime);
LocalTime ClockTime2 = LocalTime.parse(b,fmTime);
LocalTime ClockTime3 = LocalTime.parse(c,fmTime);
System.out.println("================"+ ClockTime1.isBefore(ClockTime2));
System.out.println("================"+ ClockTime2.isAfter(ClockTime3));
public String localtoString(String type) {
DateTimeFormatter df = null;
if(type.equals("1")){
df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
}else if(type.equals("2")){
df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
}
LocalDateTime time = LocalDateTime.now();
String localTime = df.format(time);
return localTime;
}
public boolean fomarttime(String type) {
DateTimeFormatter fmTime = DateTimeFormatter.ofPattern("HH:mm");
String times = type;
LocalTime ClockTime1 = LocalTime.parse(times,fmTime);
LocalTime time = LocalTime.now();
return time.isBefore(ClockTime1);
}