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
540b8cfe
Commit
540b8cfe
authored
Dec 29, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/ver1.1' into ver1.1
parents
41534ee4
50194853
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
3 deletions
+59
-3
DateHelper.java
...src/main/java/com/yanzuoguang/util/helper/DateHelper.java
+40
-0
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+6
-0
TestDateHelper.java
yzg-util-base/src/test/java/helper/TestDateHelper.java
+11
-2
AspectMq.java
...oud/src/main/java/com/yanzuoguang/cloud/aop/AspectMq.java
+2
-1
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/DateHelper.java
View file @
540b8cfe
...
@@ -363,6 +363,46 @@ public class DateHelper {
...
@@ -363,6 +363,46 @@ public class DateHelper {
return
end
.
getTime
();
return
end
.
getTime
();
}
}
/**
* 获取本周开始日期
*
* @param date 某一天
* @return 返回的日期
*/
public
static
Date
getWeekStart
(
Date
date
)
{
Calendar
cal
=
getDayCalendarBegin
(
date
);
// 周日
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
();
}
/**
* 获取本周结束日期
*
* @param date 某一天
* @return 返回的值
*/
public
static
Date
getWeekEnd
(
Date
date
)
{
Calendar
cal
=
getDayCalendarBegin
(
date
);
// 周日
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/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
540b8cfe
...
@@ -1278,6 +1278,9 @@ public class StringHelper {
...
@@ -1278,6 +1278,9 @@ public class StringHelper {
while
(
handle
)
{
while
(
handle
)
{
handle
=
false
;
handle
=
false
;
for
(
String
prefix
:
suffix
)
{
for
(
String
prefix
:
suffix
)
{
if
(
StringHelper
.
isEmpty
(
prefix
))
{
continue
;
}
if
(
from
.
startsWith
(
prefix
))
{
if
(
from
.
startsWith
(
prefix
))
{
from
=
from
.
substring
(
prefix
.
length
());
from
=
from
.
substring
(
prefix
.
length
());
handle
=
true
;
handle
=
true
;
...
@@ -1302,6 +1305,9 @@ public class StringHelper {
...
@@ -1302,6 +1305,9 @@ public class StringHelper {
while
(
handle
)
{
while
(
handle
)
{
handle
=
false
;
handle
=
false
;
for
(
String
prefix
:
suffix
)
{
for
(
String
prefix
:
suffix
)
{
if
(
StringHelper
.
isEmpty
(
prefix
))
{
continue
;
}
if
(
from
.
endsWith
(
prefix
))
{
if
(
from
.
endsWith
(
prefix
))
{
from
=
from
.
substring
(
0
,
from
.
length
()
-
prefix
.
length
());
from
=
from
.
substring
(
0
,
from
.
length
()
-
prefix
.
length
());
handle
=
true
;
handle
=
true
;
...
...
yzg-util-base/src/test/java/helper/TestDateHelper.java
View file @
540b8cfe
...
@@ -14,10 +14,19 @@ public class TestDateHelper {
...
@@ -14,10 +14,19 @@ public class TestDateHelper {
Date
date
=
new
Date
();
Date
date
=
new
Date
();
System
.
out
.
println
(
"本日:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getDayStart
(
date
)));
System
.
out
.
println
(
"本日:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getDayStart
(
date
)));
System
.
out
.
println
(
"本日:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getDayEnd
(
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
.
getMonthStart
(
date
)));
System
.
out
.
println
(
"本月:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getMonthEnd
(
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
(
"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
.
getMonth3Start
(
date
)));
System
.
out
.
println
(
"本季度:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getMonth3End
(
date
)));
System
.
out
.
println
(
"本季度:"
+
DateHelper
.
getDateTimeString
(
DateHelper
.
getMonth3End
(
date
)));
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/AspectMq.java
View file @
540b8cfe
...
@@ -62,7 +62,8 @@ public class AspectMq {
...
@@ -62,7 +62,8 @@ public class AspectMq {
String
requestBody
=
aspectLogBody
.
getRequestBody
(
message
);
String
requestBody
=
aspectLogBody
.
getRequestBody
(
message
);
LogVo
log
=
new
LogVo
();
LogVo
log
=
new
LogVo
();
boolean
clear
=
aspectLogStart
.
requestLogInit
();
boolean
clear
=
true
;
aspectLogStart
.
requestLogInit
();
aspectLogStart
.
requestLog
(
declaringType
,
TAG
,
url
,
requestBody
,
log
,
clear
);
aspectLogStart
.
requestLog
(
declaringType
,
TAG
,
url
,
requestBody
,
log
,
clear
);
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
Object
result
=
null
;
Object
result
=
null
;
...
...
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