PreparedStatement设置mysql中datetime的值精确到时分秒

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37050372/article/details/84958607

1.拿到当前时间

Date now = new Date();
mc.setCrtDate(now);
mc.setLastUpdate(now);

2.插入时的操作

pstmt.setTimestamp(7, new Timestamp(m.getCrtDate().getTime()));
pstmt.setTimestamp(8, new Timestamp(m.getLastUpdate().getTime()));

猜你喜欢

转载自blog.csdn.net/qq_37050372/article/details/84958607