Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
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
项目统一框架
amos-boot-biz
Commits
fc38528c
Commit
fc38528c
authored
Jan 05, 2023
by
lisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
23c88d80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
DateUtils.java
.../java/com/yeejoin/equipmanage/common/utils/DateUtils.java
+63
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/DateUtils.java
View file @
fc38528c
...
...
@@ -836,6 +836,69 @@ public class DateUtils {
return
dates
;
}
public
static
List
<
Map
<
String
,
String
>>
getWeeksMapInterval
(
String
date
){
List
<
Map
<
String
,
String
>>
dates
=
new
ArrayList
<>();
String
year
=
date
.
substring
(
0
,
4
);
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM"
);
Date
date1
=
null
;
try
{
date1
=
dateFormat
.
parse
(
date
);
}
catch
(
ParseException
e
)
{
System
.
out
.
println
(
"获取当前月自然周,日期格式转换错误!11"
);
e
.
printStackTrace
();
}
Calendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTime
(
date1
);
int
days
=
calendar
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
);
int
count
=
0
;
for
(
int
i
=
1
;
i
<=
days
;
i
++)
{
DateFormat
dateFormat1
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
date2
=
null
;
try
{
date2
=
dateFormat1
.
parse
(
date
+
"-"
+
i
);
}
catch
(
ParseException
e
)
{
System
.
out
.
println
(
"获取当前月自然周,日期格式转换错误!22"
);
e
.
printStackTrace
();
}
calendar
.
clear
();
calendar
.
setTime
(
date2
);
int
k
=
new
Integer
(
calendar
.
get
(
Calendar
.
DAY_OF_WEEK
));
int
startDay
=
0
;
int
endDay
=
0
;
// 若当天是周日
if
(
k
==
1
)
{
count
++;
if
(
i
-
6
<=
1
)
{
startDay
=
1
;
}
else
{
startDay
=
i
-
6
;
}
endDay
=
i
;
}
// 若是本月最好一天,且不是周日
if
(
k
!=
1
&&
i
==
days
)
{
count
++;
startDay
=
i
-
k
+
2
;
endDay
=
i
;
}
if
(
startDay
!=
0
&&
endDay
!=
0
){
String
s
=
year
+
"第"
+
getWeekOfYear
(
date2
)
+
"周"
+
"("
+
date
.
substring
(
5
)
+
"月"
+
startDay
+
"日至"
+
date
.
substring
(
5
)
+
"月"
+
endDay
+
"日"
+
")"
;
String
weekStart
=
year
+
"-"
+
date
.
substring
(
5
)
+
"-"
+
startDay
+
" 00:00:00"
;
String
weekEnd
=
year
+
"-"
+
date
.
substring
(
5
)
+
"-"
+
endDay
+
" 23:59:59"
;
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"name"
,
s
);
map
.
put
(
"weekStart"
,
weekStart
);
map
.
put
(
"weekEnd"
,
weekEnd
);
dates
.
add
(
map
);
}
}
return
dates
;
}
/**
* 获取一年的第几周
*
...
...
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