1. 程式人生 > >sql中如何將string型時間存入到資料庫中date型時間中呢?

sql中如何將string型時間存入到資料庫中date型時間中呢?

方法
String Nowtime=new SimpleDateFormat(“yyyy-MM-dd”).format(new Date());//一個string型別的當前時間
java.sql.Date mysqldate=java.sql.Date.valueOf(Nowtime);//將string型寫入資料庫date型

以下以hibernate內為例子
在這裡插入圖片描述
儲存當前時間string型到資料庫中date型