自定义订单号问题

public class GetNow {
    public static String getNow() {
        return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    }
}

  public Order(String orderNum, Boolean sex, int age, String occasion, String functionalDesc, String colorDesc, String materialDesc, BigDecimal price, Long number, BigDecimal totalPrice, BigDecimal payPrice, Date bookingDate, Date payTime, Boolean payStatus, OrderStatus orderStatus, Date deliveryDate, String remark, Customer customer, User user, Design design) {
    this.orderNum = getOrderNum();

打印不出订单号,

单元测试是可以获取到的

如果要用格式化时间字符串来作为订单号的话建议使用LocalDateTime来操作
SDF和Date会有多线程并发问题

1 Like