Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
216dccec
Commit
216dccec
authored
Nov 24, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.0-SNAPSHOT的支持
parent
afc8e07f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
DateHelper.java
...src/main/java/com/yanzuoguang/util/helper/DateHelper.java
+26
-0
TestDateHelper.java
yzg-util-base/src/test/java/helper/TestDateHelper.java
+5
-2
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/DateHelper.java
View file @
216dccec
...
...
@@ -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
();
}
/**
* 获取本月开始时间
...
...
yzg-util-base/src/test/java/helper/TestDateHelper.java
View file @
216dccec
...
...
@@ -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
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment