1、数据库字段
注:该字段应该是DATE类型
2、java保存时间写法
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.err.println(Timestamp.valueOf(sdf.format(dt)));
Date dt2 = new Date();
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.err.println(Timestamp.valueOf(sdf2.format(dt2)));
运行结果:
2019-06-20 05:38:41.0
2019-06-20 17:38:41.0
故:hh表示12小时制,HH表示24小时制
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
pm.set("UPDATE_TIME", Timestamp.valueOf(sdf.format(dt)));
参考:
select TO_CHAR(a.last_login_time,'YY/MM/DD HH24:MI:SS') ,a.* from JC_USER a where a.USERNAME ='admin'