Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
18dbe93d
Commit
18dbe93d
authored
Aug 04, 2026
by
wujipeng
Browse files
优化
parent
3b1e1453
Changes
1
Hide whitespace changes
Inline
Side-by-side
practical-business/src/main/java/com/platform/business/service/impl/ClassServiceImpl.java
View file @
18dbe93d
...
...
@@ -117,7 +117,7 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
}
List
<
ExamStudentVO
>
examStudentChildList
=
Lists
.
newArrayList
();
for
(
ExamStudentVO
examStudentVO
:
examStudentList
)
{
if
(
isSameDayWithFormat
(
examStudentVO
.
getExamTime
()
.
split
(
"-"
)[
0
]
,
date
))
{
if
(
isSameDayWithFormat
(
examStudentVO
.
getExamTime
(),
date
))
{
examStudentChildList
.
add
(
examStudentVO
);
}
}
...
...
@@ -239,7 +239,7 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
}
List
<
ExamStudentVO
>
examStudentChildList
=
Lists
.
newArrayList
();
for
(
ExamStudentVO
examStudentVO
:
examStudentList
)
{
if
(
isSameDayWithFormat
(
examStudentVO
.
getExamTime
()
.
split
(
"-"
)[
0
]
,
date
))
{
if
(
isSameDayWithFormat
(
examStudentVO
.
getExamTime
(),
date
))
{
examStudentChildList
.
add
(
examStudentVO
);
}
}
...
...
@@ -310,20 +310,13 @@ public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> impl
* 方法2: 使用SimpleDateFormat格式化比较
* 将日期格式化为"yyyyMMdd"后比较字符串
*
* @param date
Str 日期字符串,格式:yyyy.MM.dd HH:mm:ss
* @param
compareDate 要比较的
Date对象
* @param date
1 第一个Date对象
* @param
date2 第二个
Date对象
* @return 是否为同一天
*/
public
static
boolean
isSameDayWithFormat
(
String
dateStr
,
Date
compareDate
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy.MM.dd HH:mm:ss"
);
Date
inputDate
=
sdf
.
parse
(
dateStr
);
SimpleDateFormat
dayFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
return
dayFormat
.
format
(
inputDate
).
equals
(
dayFormat
.
format
(
compareDate
));
}
catch
(
ParseException
e
)
{
throw
new
IllegalArgumentException
(
"日期格式错误,应为: yyyy.MM.dd HH:mm:ss"
,
e
);
}
public
static
boolean
isSameDayWithFormat
(
Date
date1
,
Date
date2
)
{
SimpleDateFormat
dayFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
return
dayFormat
.
format
(
date1
).
equals
(
dayFormat
.
format
(
date2
));
}
/**
...
...
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