diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java index e8eb47f5..6bbe2adc 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java @@ -44,11 +44,11 @@ public class PropCouponConvertor { co.setSource(propCoupon.getSource().getCode()); co.setSourceName(propCoupon.getSource().getDesc()); - Timestamp timestamp = ZonedDateTimeUtils.toTimestamp(propCoupon.getExpireTime()); + Timestamp timestamp = ZonedDateTimeUtils.toTimestampDefault(propCoupon.getExpireTime()); co.setExpireTime(timestamp); co.setExpireSeconds(Math.abs(Duration.between(propCoupon.getExpireTime(), LocalDateTime.now()).getSeconds())); - co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getUseTime())); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getCreateTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestampDefault(propCoupon.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(propCoupon.getCreateTime())); return co; } @@ -89,9 +89,9 @@ public class PropCouponConvertor { co.setSourceName(source.getDesc()); } - co.setExpireTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getExpireTime())); - co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getUseTime())); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getCreateTime())); + co.setExpireTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getExpireTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getCreateTime())); return co; } @@ -127,7 +127,7 @@ public class PropCouponConvertor { co.setReceiverId(recordDO.getReceiverId()); co.setRemark(recordDO.getRemark()); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(recordDO.getCreateTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(recordDO.getCreateTime())); return co; } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java index 5ec4a65b..f3f56cb3 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java @@ -465,6 +465,13 @@ public final class ZonedDateTimeUtils { return Timestamp.from(localDateTime.atZone(ZonedId.ASIA_RIYADH.getZonedId()).toInstant()); } + public static Timestamp toTimestampDefault(LocalDateTime localDateTime) { + if (localDateTime == null) { + return null; + } + return Timestamp.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + /** * 转换zoneId *