How to convert string date to Timestamp in java?

后端 未结 6 813
臣服心动
臣服心动 2020-12-03 13:15

I want to convert string Date into Timestamp in java. The following coding i have written.I have declare the date for date1 is: 7-11-11 12:13:14.

SimpleDateF         


        
6条回答
  •  北海茫月
    2020-12-03 13:46

    You can convert String to Timestamp:

    String inDate = "01-01-1990"
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
    Timestamp ts = new Timestamp(((java.util.Date)df.parse(inDate)).getTime());
    

提交回复
热议问题