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