From aa6debfa64d54cb68704a784e928d923e66f0eb8 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期六, 28 十二月 2024 13:59:59 +0800 Subject: [PATCH] 临时任务完善 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java | 61 +++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java index c5c1bc4..ac86459 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java @@ -26,6 +26,46 @@ public static Date getDate(Long time){ return new Date(time) ; } + + + + public static Date startOfDay(int year, int month, int day){ + Date dt = null ; + try{ + dt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(year + "-" + (month < 10 ? ("0" + month) : month) + "-" + (day < 10 ? ("0" + day) : day) + " 00:00:00"); + }catch (Exception e){ + e.printStackTrace(); + } + return dt ; + } + + public static Date endOfDay(int year, int month, int day){ + Date dt = null ; + try{ + dt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(year + "-" + (month < 10 ? ("0" + month) : month) + "-" + (day < 10 ? ("0" + day) : day) + " 23:59:59"); + }catch (Exception e){ + e.printStackTrace(); + } + return dt ; + } + + public static int endDayOfMonth(int year, int month){ + if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ + return 31 ; + }else{ + if(month == 2){ + if(DateTime.isLeapYear(year)){ + return 29 ; + }else{ + return 28 ; + } + }else{ + return 30 ; + } + } + } + + public static String yyyy() { return new SimpleDateFormat("yyyy", Locale.CHINA).format(new Date(System.currentTimeMillis())); @@ -423,7 +463,7 @@ case "鍛ㄥ洓" -> 4; case "鍛ㄤ簲" -> 5; case "鍛ㄥ叚" -> 6; - case "鍛ㄤ竷" -> 7; + case "鍛ㄤ竷" -> 0;//鏍规嵁鍗忚瑕佹眰鏄熸湡澶╀负0 default -> 0; }; }else{ @@ -434,7 +474,7 @@ case "Thu" -> 4; case "Fri" -> 5; case "Sat" -> 6; - case "Sun" -> 7; + case "Sun" -> 0;//鏍规嵁鍗忚瑕佹眰鏄熸湡澶╀负0 default -> 0; }; } @@ -484,6 +524,12 @@ /** * 涓や釜鏃ユ湡鐩稿樊澶╂暟 */ + public static long daysBetweenyyyy_MM_dd(Date yyyy_MM_dd_1 , Date yyyy_MM_dd_2)throws Exception{ + return ((((yyyy_MM_dd_1.getTime() - yyyy_MM_dd_2.getTime())/1000)/60)/60)/24 ; + } + /** + * 涓や釜鏃ユ湡鐩稿樊澶╂暟 + */ public static long daysBetweenyyyyMMdd(String yyyyMMdd_1 , String yyyyMMdd_2)throws Exception{ return ((((dateFrom_yyyy_MM_dd(yyyyMMdd_1).getTime()-dateFrom_yyyy_MM_dd(yyyyMMdd_2).getTime())/1000)/60)/60)/24 ; } @@ -501,6 +547,17 @@ ////////////////////////////////////////////////////////////////////////// /** + * 瀛楃涓插瀷鏃ユ湡(2024-12)杞垚骞存湀鏃ユ暟缁� + * @param yyyy_MM 骞存湀鏃� + * @return 骞存湀鏃ユ暟缁� + */ + public static int[] yyyy_MM_ymdGroup(String yyyy_MM){ + int y = Integer.parseInt(yyyy_MM.substring(0 , 4)) ; + int m = Integer.parseInt(yyyy_MM.substring(5 , 7)) ; + return new int[]{y,m} ; + } + + /** * 瀛楃涓插瀷鏃ユ湡(2009-09-10)杞垚骞存湀鏃ユ暟缁� * @param yyyy_MM_DD 骞存湀鏃� * @return 骞存湀鏃ユ暟缁� -- Gitblit v1.8.0