微信APP支付回調函數“time_end”的坑

在微信支付成功後,微信是會給我們的回調地址發送成功信息,具體可以看官方文檔:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_7&index=3

返回信息中有一個“time_end”字段,具體返回的值是“20200629140553”,因爲我數據庫裏面存時間的類型是datetime,所以在存的時候會報很多時間類型的錯誤,百度上亂七八糟的答案都有,試了很多種方法,然而無果,最後自己使用了SimpleDateFormat類進行三次轉換得到了最終想要的date日期格式。

SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
Date parse=simpleDateFormat1.parse(payTime);
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format=simpleDateFormat2.format(parse);
memberCardTrxorderDetail.setPayTime(simpleDateFormat2.parse(format));

終於解決了"20200629140553"轉爲date日期格式2020-06-29 14:05:53

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章