关键词搜索

源码搜索 ×
×

获取 当前日期、当前时间、前一天日期

发布2021-01-17浏览668次

详情内容

 /**
     * 获取前一天日期
     *
     * @return
     */
    public String getYesterday() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, -1); //得到前一天
        Date date = calendar.getTime();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        return df.format(date);
    }

    /**
     * 获取当前日期
     *
     * @return
     */
    public String getCurrentDate() {
        LocalDateTime dateTime = LocalDateTime.now();
        DateTimeFormatter currentDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return dateTime.format(currentDate);
    }

    /**
     * 获取当前时间
     *
     * @return
     */
    public String getCurrentTime() {
        LocalDateTime dateTime = LocalDateTime.now();
        DateTimeFormatter currenTime = DateTimeFormatter.ofPattern("HH:mm:ss");
        return dateTime.format(currenTime);
    }

    Hxprocesslog hxprocesslog = new Hxprocesslog();
    //         Date tStartDate = new Date();
    //         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    //         DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
    //         hxprocesslog.setMakedate(dateFormat.parse(dateFormat.format(tStartDate)));
    //         hxprocesslog.setMaketime(timeFormat.format(tStartDate));
    //         hxprocesslog.setModifytime(timeFormat.format(tStartDate));
    //         hxprocesslog.setModifydate(dateFormat.parse(dateFormat.format(tStartDate)));
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    相关技术文章

    点击QQ咨询
    开通会员
    返回顶部
    ×
    微信扫码支付
    微信扫码支付
    确定支付下载
    请使用微信描二维码支付
    ×

    提示信息

    ×

    选择支付方式

    • 微信支付
    • 支付宝付款
    确定支付下载