From 9bef6f6e735d16d2ec04c12028c3df6cdeccf1a5 Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期一, 27 九月 2021 10:58:31 +0800 Subject: [PATCH] Merge branch 'test_bak' into 'test' --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java | 15 +++++++++++++++ 1 files changed, 15 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 53eeaf8..e45a7d3 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,7 @@ 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"); /** * 将日期对象格式化成指定的字符串格式 @@ -759,6 +760,12 @@ return instance.get(Calendar.MONTH); } + public static int getYear(Date date) { + Calendar instance = Calendar.getInstance(); + instance.setTime(date); + return instance.get(Calendar.YEAR); + } + public static boolean before(Date start, Date end) { Calendar date1 = Calendar.getInstance(); date1.setTime(start); @@ -884,6 +891,14 @@ // Date after = new Date(); // System.out.println(getFirstDayOfMonthString()); // System.out.println(getDayOfMonthString()); + } + /** + * 获取当前年月字符串 + * @return 年月字符串 + */ + public static String getCurrentDateString_YYYY_MM() { + String nowtime = getCurrentDate().format(format_yms); + return nowtime; } } -- Gitblit v1.7.1