From 09c6af7d0c851b366e1ccd4685351c7dba667763 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期四, 30 九月 2021 14:17:35 +0800 Subject: [PATCH] Merge branch 'test' of http://gitlab.nhys.cdnhxx.com/root/zhihuishequ into test --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java index d40778e..8459cff 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java @@ -25,6 +25,8 @@ public static SimpleDateFormat format_yyymmdd = new SimpleDateFormat("yyyyMMdd"); private static DateTimeFormatter format_ymdhmssss = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); private static DateTimeFormatter format_ymds = DateTimeFormatter.ofPattern("yyyyMMdd"); + private static DateTimeFormatter format_yms = DateTimeFormatter.ofPattern("yyyyMM"); + private static DateTimeFormatter format_y = DateTimeFormatter.ofPattern("yyyy"); /** * 将日期对象格式化成指定的字符串格式 @@ -891,4 +893,22 @@ // System.out.println(getFirstDayOfMonthString()); // System.out.println(getDayOfMonthString()); } + + /** + * 获取当前年月字符串 + * @return 年月字符串 + */ + public static String getCurrentDateString_YYYY_MM() { + String nowtime = getCurrentDate().format(format_yms); + return nowtime; + } + + /** + * 获取当前年字符串 + * @return + */ + public static String getCurrentDateString_YYYY() { + String nowtime = getCurrentDate().format(format_y); + return nowtime; + } } -- Gitblit v1.7.1