微信APP支付回调函数“time_end”的坑

海豚精灵https://mgo.whhtjl.com

在微信支付成功后,微信是会给我们的回调地址发送成功信息,具体可以看官方文档: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

猜你喜欢

转载自blog.csdn.net/qq_35393693/article/details/107019438