for (GiftBox giftBox : giftBoxList) { java.util.Date nowdate = new java.util.Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //未过期的礼品 if (sdf.parse(giftBox.getEndDate()).before(nowdate) == false) { // 查询商品 Goods goods = getGoodsInfoByIdForShopcart(giftBox.getGoodsId()); goods.setBoxId(giftBox.getBoxId()); goods.setOrderAmount(giftBox.getGoodsAmount()); goods.setPromotePhrase(null); goods.setFinalPrice(new BigDecimal(0.00)); goods.setSumPrice(new BigDecimal(0.00)); goodsList.add(goods); } }