how to convert datetime to timestamp in java

前端 未结 5 2050
萌比男神i
萌比男神i 2021-01-22 21:24

forum member

I am having one problem with date time in java. Actually I am receiving the startdate in format 2012-02-27T01:10:10 and I want to insert th

5条回答
  •  遇见更好的自我
    2021-01-22 22:18

    String sDate = jsonObject.get("StartDate").toString();
    String eDate = jsonObject.get("EndDate").toString();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
    Date startD = sdf.format(sDate);
    Timestamp startTime = new Timestamp(startD.getTime());
    
    Date endD = sdf.format(eDate);
    Timestamp endTime = new Timestamp(endD.getTime());
    

提交回复
热议问题