java.sql.Date与java.sql.Date区别

时间:2022-01-10 05:20:25

public static void main(String[] args) {
    java.sql.Date createTime = new java.sql.Date(System.currentTimeMillis()-5400000);
    System.out.println("sql date: " createTime);

    Date create_time = new Date(System.currentTimeMillis()-5400000);
    System.out.println("util date: "  create_time);
    System.out.println("格式化: " DateUtils.date2Str(create_time,DateUtils.datetimeFormat));
}

结果

sql date: 2019-11-06
util date: Wed Nov 06 08:38:37 CST 2019
格式化: 2019-11-06 08:38:37

java.sql.Date只能精确到天