我的dao页面从两个不同的字段接收日期和时间,现在我想知道如何将这两个日期和时间合并成一个对象,以便我可以计算时间差和总时间。我有这段代码来合并,但它不起作用,请问我在这段代码中做错了什么,请帮忙。
Date d = new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-02");
Date t = new SimpleDateFormat("hh:mm:ss").parse("04:05:06");
LocalDate datePart = new LocalDate(d);
LocalTime timePart = new LocalTime(t);
LocalDateTime dateTime = datePart.toLocalDateTime(timePart);
System.out.println(dateTime);
t
实际上不是时间,而是日期。1970年1月1日上午4:05。 - Boris the Spidert.toInstant().atZone(ZoneId.systemDefault()).toLocalTime()
。当你遇到java.sql.Time
实例时,你必须处理这种模式... - Holger