From 51ecf7afc63d6353de21f29bd66c7a0ab5f4aa96 Mon Sep 17 00:00:00 2001 From: xyiege Date: Wed, 23 Nov 2022 17:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=9B=A0=E5=AF=B9=E6=96=B9?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=BC=BA=E5=A4=B1=E5=AF=BC=E8=87=B4=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/chjyj/szwh/utils/ApiGoodsUtils.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java b/src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java index 02afee4..6483eac 100644 --- a/src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java +++ b/src/main/java/cn/chjyj/szwh/utils/ApiGoodsUtils.java @@ -5,6 +5,8 @@ import cn.chjyj.szwh.bean.GoodsDetail; import cn.chjyj.szwh.bean.GoodsSource; import com.alibaba.fastjson2.JSONObject; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.math.BigDecimal; import java.text.SimpleDateFormat; @@ -15,6 +17,7 @@ import java.util.Date; * 处理api数据,转为bean */ public class ApiGoodsUtils { + private static Log log = LogFactory.getLog(ApiGoodsUtils.class); /** * 从json字符串中抽取对象 @@ -164,12 +167,20 @@ public class ApiGoodsUtils { goodsDetail.setDataJson(nodejson.toJSONString()); goodsDetail.setSourceJson(json.toJSONString()); String sdate= json.getString("releaseTime"); - try { - Date createTime = sdf.parse(sdate); - goodsDetail.setCreatetime(createTime); - goodsDetail.setUpdatetime(createTime); - }catch (Exception ex){ - //do nothing + //如果时间为空 + if(StringUtils.isNotEmpty(sdate)) { + try { + Date createTime = sdf.parse(sdate); + goodsDetail.setCreatetime(createTime); + goodsDetail.setUpdatetime(createTime); + } catch (Exception ex) { + //do nothing + log.error("商品详情createtime错误:" + ex.getStackTrace().toString()); + } + }else { + Date now =new Date(); + goodsDetail.setCreatetime(now); + goodsDetail.setUpdatetime(now); } //其他状态 goodsDetail.setIsDeleted(0);