Java date to sql date

前端 未结 2 1904
無奈伤痛
無奈伤痛 2020-12-12 06:31

How can I store a specific date from java to my database? (Not only the date today, but also some dates that the user wants to specifiy)

try {
        Simpl         


        
2条回答
  •  春和景丽
    2020-12-12 07:02

    use this it can help

      static  java.sql.Timestamp getSqlDate(Date date) {    
            java.util.Date javaDate = date;
            long javaTime = javaDate.getTime();
            java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(javaTime);
            return sqlTimestamp;
     }
    

提交回复
热议问题