Commit 216dccec authored by yanzg's avatar yanzg

1.0-SNAPSHOT的支持

parent afc8e07f
......@@ -363,6 +363,32 @@ public class DateHelper {
return end.getTime();
}
/**
* 获取本周开始日期
*
* @param date 某一天
* @return 返回的日期
*/
public static Date getWeekStart(Date date) {
Calendar cal = getDayCalendarBegin(date);
cal.setWeekDate(cal.getWeekYear(), cal.get(Calendar.WEEK_OF_YEAR), 2);
setDayStart(cal);
return cal.getTime();
}
/**
* 获取本周结束日期
*
* @param date 某一天
* @return 返回的值
*/
public static Date getWeekEnd(Date date) {
Calendar cal = getDayCalendarBegin(date);
cal.setWeekDate(cal.getWeekYear(), cal.get(Calendar.WEEK_OF_YEAR) + 1, 1);
setDayEnd(cal);
return cal.getTime();
}
/**
* 获取本月开始时间
......
......@@ -14,10 +14,13 @@ public class TestDateHelper {
Date date = new Date();
System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayStart(date)));
System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayEnd(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearStart(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearEnd(date)));
System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthStart(date)));
System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthEnd(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearStart(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearEnd(date)));
System.out.println("本周:" + DateHelper.getDateTimeString(DateHelper.getWeekStart(date)));
System.out.println("本周:" + DateHelper.getDateTimeString(DateHelper.getWeekEnd(date)));
System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3Start(date)));
System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3End(date)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment