生成订单号(利用时间转化)

生成订单号(利用时间转化)

 /**
     *  订单号生成   20200718112629527
     */
    public static String nextItemNo(){
        LocalDateTime dateTime = LocalDateTime.now();
        return DateLiuUtil.getOtherFormatterLocalDateTime(dateTime);
    }

PS:LocalDateTime源码

 /**
     * Obtains the current date-time from the system clock in the default time-zone.
     * <p>
     * This will query the {@link Clock#systemDefaultZone() system clock} in the default
     * time-zone to obtain the current date-time.
     * <p>
     * Using this method will prevent the ability to use an alternate clock for testing
     * because the clock is hard-coded.
     *
     * @return the current date-time using the system clock and default time-zone, not null
     */
    public static LocalDateTime now() {
        return now(Clock.systemDefaultZone());
    }

PS:getOtherFormatterLocalDateTime源码

 /**
     * 格式化日期格式 yyyy-MM-dd HH:mm:ss
     *
     * @param localDateTime 传入需要格式化的日期
     * @return 返回格式化后的日期字符串
     */
    public static String getOtherFormatterLocalDateTime(LocalDateTime localDateTime) {
        DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(DEFAULT_PATTERN_DATETIME_SIMPLE_FULL);
        return getLocalDateTimeFormat(localDateTime, dateTimeFormatter);
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值