Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
b285b4b8
Commit
b285b4b8
authored
Aug 03, 2022
by
李灿灿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字符串格式的日期转LocalDate工具类调整
parent
042086ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
LocalDateUtil.java
...ifu/cloud/plus/v1/yifu/insurances/util/LocalDateUtil.java
+9
-5
No files found.
yifu-insurances/yifu-insurances-api/src/main/java/com/yifu/cloud/plus/v1/yifu/insurances/util/LocalDateUtil.java
View file @
b285b4b8
...
...
@@ -7,6 +7,7 @@ import java.text.DateFormat;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Calendar
;
import
java.util.Date
;
...
...
@@ -75,11 +76,14 @@ public class LocalDateUtil {
*/
public
static
LocalDate
parseLocalDate
(
String
strDate
){
try
{
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
NORM_DATE_PATTERN
,
Locale
.
CHINA
);
LocalDate
localDate
=
LocalDate
.
parse
(
strDate
,
dateTimeFormatter
);
return
localDate
;
if
(
isDate
(
strDate
,
NORM_DATE_PATTERN
)){
DateFormat
dateFormat
=
new
SimpleDateFormat
(
NORM_DATE_PATTERN
);
Date
date
=
dateFormat
.
parse
(
strDate
);
return
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
}
return
null
;
}
catch
(
Exception
e
){
e
.
printStackTrace
(
);
System
.
out
.
println
(
"字符串格式的日期转LocalDate失败"
);
return
null
;
}
}
...
...
@@ -337,6 +341,6 @@ public class LocalDateUtil {
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
isOverdueDate
(
"2022-08-0
3"
));
System
.
out
.
println
(
parseLocalDate
(
"2022-8-
3"
));
}
}
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