From 72f11c9e9edec3d2534112badf7a0ca48fa9da5a Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期三, 23 六月 2021 14:37:44 +0800 Subject: [PATCH] Merge branch 'test' into 'test_wangge_two' --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 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 4c6681d..74b43ce 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 @@ -34,6 +34,8 @@ public static DateTimeFormatter format_ymd_String = DateTimeFormatter.ofPattern("yyMMdd"); + public static SimpleDateFormat yyyyMM_format = new SimpleDateFormat("yyyy-MM"); + /** @@ -124,6 +126,13 @@ return now; } + /** + * 返回当前事件的时间戳 + * @return + */ + public static Long getCurrentDateTimeStamp(){ + return LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); + } /** * 获取当前时间字符串,格式为yyyy-MM-dd HH:mm:ss * @return @@ -711,16 +720,43 @@ return cal.getTime(); } + public static Date getDateM(Date start, int min) { + Calendar date1 = Calendar.getInstance(); + date1.setTime(start); + date1.add(Calendar.MONTH, min); + return date1.getTime(); + } + public static Date parseDateYM(String str) { + try { + return yyyyMM_format.parse(str); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + + public static int getMonth(Date date){ + Calendar instance = Calendar.getInstance(); + instance.setTime(date); + return instance.get(Calendar.MONTH); + } + + public static boolean before(Date start, Date end){ + Calendar date1 = Calendar.getInstance(); + date1.setTime(start); + Calendar date2 = Calendar.getInstance(); + date2.setTime(end); + return date1.before(date2); + } public static void main(String[]args)throws Exception{ - isValidDate("2020/12/4"); // Date date= new Date(); // Date after = new Date(); // System.out.println(calTimeDifference(date,after)); - System.out.println(getYearMonthStart(2021,2)); } } -- Gitblit v1.7.1