From 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 20 十一月 2024 15:30:12 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/utils/DateUtils.java |   61 +++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/yssh/utils/DateUtils.java b/src/main/java/com/yssh/utils/DateUtils.java
index f8ca337..5d9786c 100644
--- a/src/main/java/com/yssh/utils/DateUtils.java
+++ b/src/main/java/com/yssh/utils/DateUtils.java
@@ -5,13 +5,9 @@
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import com.yssh.config.InitConfig;
 import org.apache.commons.lang3.time.DateFormatUtils;
 
-/**
- * 鏃堕棿宸ュ叿绫�
- * 
- * @author tam
- */
 public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 	public static String YYYY = "yyyy";
 
@@ -37,20 +33,7 @@
 			"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss",
 			"yyyy.MM.dd HH:mm", "yyyy.MM"};
 
-	/**
-	 * 鑾峰彇褰撳墠Date鍨嬫棩鏈�
-	 *
-	 * @return Date() 褰撳墠鏃ユ湡
-	 */
-	public static Date getNowDate() {
-		return new Date();
-	}
 
-	/**
-	 * 鑾峰彇褰撳墠鏃ユ湡, 榛樿鏍煎紡涓簓yyy-MM-dd
-	 *
-	 * @return String
-	 */
 	public static String getDate() {
 		return dateTimeNow(YYYY_MM_DD);
 	}
@@ -64,7 +47,7 @@
 	}
 
 	public static final String dateTimeNow(final String format) {
-		return parseDateToStr(format, new Date());
+		return parseDateToStr(format, InitConfig.getDate());
 	}
 
 	public static final String dateTime(final Date date) {
@@ -103,16 +86,14 @@
 	 * 鏃ユ湡璺緞 鍗冲勾/鏈�/鏃� 濡�2018/08/08
 	 */
 	public static final String datePath() {
-		Date now = new Date();
-		return DateFormatUtils.format(now, "yyyy/MM/dd");
+		return DateFormatUtils.format(InitConfig.getDate(), "yyyy/MM/dd");
 	}
 
 	/**
 	 * 鏃ユ湡璺緞 鍗冲勾/鏈�/鏃� 濡�20180808
 	 */
 	public static final String dateTime() {
-		Date now = new Date();
-		return DateFormatUtils.format(now, "yyyyMMdd");
+		return DateFormatUtils.format(InitConfig.getDate(), "yyyyMMdd");
 	}
 
 	/**
@@ -263,6 +244,40 @@
 	}
 
 	/**
+	 * 鑾峰彇涓�骞翠腑鐨勭鍑犲懆
+	 */
+	public static int getWeekOfYear(Date date) {
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+
+		return cal.get(Calendar.WEEK_OF_YEAR);
+	}
+
+	/**
+	 * 鑾峰彇涓�骞翠腑鐨勭鍑犲懆鐨勬槦鏈熶竴
+	 */
+	public static Date getWeekOfYearForMon(int year, int weekOfYear) {
+		Calendar cal = Calendar.getInstance();
+		cal.set(Calendar.YEAR, year);
+		cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+		cal.set(Calendar.WEEK_OF_YEAR, weekOfYear);
+
+		return cal.getTime();
+	}
+
+	/**
+	 * 鑾峰彇涓�骞翠腑鐨勭鍑犲懆鐨勬槦鏈熸棩
+	 */
+	public static Date getWeekOfYearForSun(int year, int weekOfYear) {
+		Calendar cal = Calendar.getInstance();
+		cal.set(Calendar.YEAR, year);
+		cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+		cal.set(Calendar.WEEK_OF_YEAR, weekOfYear);
+
+		return cal.getTime();
+	}
+
+	/**
 	 * 鑾峰彇鏈湀绗竴澶�
 	 **/
 	public static Date getMonthStart(Date date) {

--
Gitblit v1.9.3