您只需要使用正确的方法,而不是调用构造函数即可。使用
parse创建本地日期和本地时间对象,那么这两个对象传递给
of方法
LocalDateTime:
LocalDate datePart = LocalDate.parse("2013-01-02"); LocalTime timePart = LocalTime.parse("04:05:06"); LocalDateTime dt = LocalDateTime.of(datePart, timePart);编辑
显然,您需要组合两个
Date对象而不是2个字符串。我想您可以先使用将两个日期转换为字符串
SimpleDateFormat。然后使用上面显示的方法。
String startingDate = new SimpleDateFormat("yyyy-MM-dd").format(startDate);String startingTime = new SimpleDateFormat("hh:mm:ss").format(startTime);


