The pit of WeChat APP payment callback function "time_end"

Dolphin Elf : https://mgo.whhtjl.com

After the WeChat payment is successful, WeChat will send a success message to our callback address. For details, please refer to the official document: https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter= 9_7&index=3

There is a "time_end" field in the returned information, and the specific returned value is "20200629140553". Because the type of time stored in my database is datetime, many time-type errors will be reported when it is stored. There are messy answers on Baidu. I tried many methods, but to no avail, finally I used the SimpleDateFormat class to perform three conversions to get the final date format that I wanted.

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));

Finally solved the problem of converting "20200629140553" to date format 2020-06-29 14:05:53

 

Guess you like

Origin blog.csdn.net/qq_35393693/article/details/107019438