我正在尝试将当前系统的时间和日期与输入字符串时间和日期进行比较。我LocalDateTime.now()
用来获取系统当前时间,也DateTimeFormatter
用来将其格式化为 dd-MM-yyyy HH:mm 模式
static DateTimeFormatter frmt = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
static LocalDateTime time = LocalDateTime.now();
这是我所拥有的:
System.out.print("Enter the Appointment new Date and Time as dd-mm-yyyy hh:mm : ");
String dateAndTime = input.nextLine();
if (//dateAndTime is before or equals the current system time)
{
System.out.println("The new date and time should be after the current time");
}
else
{
System.out.println("Appointment has been updated");
}