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
495c56c6
Commit
495c56c6
authored
Nov 27, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ver1.1' of
http://192.168.0.204/yzg/yzg-util
parents
2e66e257
f7e415f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
DateHelper.java
...src/main/java/com/yanzuoguang/util/helper/DateHelper.java
+16
-2
TestDateHelper.java
yzg-util-base/src/test/java/helper/TestDateHelper.java
+6
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/DateHelper.java
View file @
495c56c6
...
...
@@ -371,7 +371,14 @@ public class DateHelper {
*/
public
static
Date
getWeekStart
(
Date
date
)
{
Calendar
cal
=
getDayCalendarBegin
(
date
);
cal
.
setWeekDate
(
cal
.
getWeekYear
(),
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
),
2
);
// 周日
int
weekOfYear
;
if
(
cal
.
get
(
Calendar
.
DAY_OF_WEEK
)
==
Calendar
.
SUNDAY
)
{
weekOfYear
=
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
)
-
1
;
}
else
{
weekOfYear
=
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
);
}
cal
.
setWeekDate
(
cal
.
getWeekYear
(),
weekOfYear
,
2
);
setDayStart
(
cal
);
return
cal
.
getTime
();
}
...
...
@@ -384,7 +391,14 @@ public class DateHelper {
*/
public
static
Date
getWeekEnd
(
Date
date
)
{
Calendar
cal
=
getDayCalendarBegin
(
date
);
cal
.
setWeekDate
(
cal
.
getWeekYear
(),
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
)
+
1
,
1
);
// 周日
int
weekOfYear
;
if
(
cal
.
get
(
Calendar
.
DAY_OF_WEEK
)
==
Calendar
.
SUNDAY
)
{
weekOfYear
=
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
);
}
else
{
weekOfYear
=
cal
.
get
(
Calendar
.
WEEK_OF_YEAR
)
+
1
;
}
cal
.
setWeekDate
(
cal
.
getWeekYear
(),
weekOfYear
,
1
);
setDayEnd
(
cal
);
return
cal
.
getTime
();
}
...
...
yzg-util-base/src/test/java/helper/TestDateHelper.java
View file @
495c56c6
...
...
@@ -21,6 +21,12 @@ public class TestDateHelper {
System
.
out
.
println
(
"本周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekStart
(
date
)));
System
.
out
.
println
(
"本周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekEnd
(
date
)));
System
.
out
.
println
(
"2022-11-27 周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekStart
(
DateHelper
.
getDateTime
(
"2022-11-27"
))));
System
.
out
.
println
(
"2022-11-27 周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekEnd
(
DateHelper
.
getDateTime
(
"2022-11-27"
))));
System
.
out
.
println
(
"2022-11-26 周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekStart
(
DateHelper
.
getDateTime
(
"2022-11-26"
))));
System
.
out
.
println
(
"2022-11-26 周:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getWeekEnd
(
DateHelper
.
getDateTime
(
"2022-11-26"
))));
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