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
f555341d
Commit
f555341d
authored
Aug 26, 2022
by
李灿灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-licancan' into 'develop'
Feature licancan See merge request fangxinjiang/yifu!196
parents
ec71999d
a064a4d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
IdCardUtil.java
.../yifu/cloud/plus/v1/yifu/common/core/util/IdCardUtil.java
+6
-6
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/IdCardUtil.java
View file @
f555341d
...
...
@@ -33,7 +33,6 @@ public class IdCardUtil {
/**
* 根据身份证号计算周岁
* 例如:当前时间是2022-08-22,那么2007-08-22算15周岁,2007-08-23才算16周岁
*
* @author licancan
* @param idNO
...
...
@@ -58,11 +57,12 @@ public class IdCardUtil {
int
yearBirth
=
bir
.
get
(
Calendar
.
YEAR
);
int
monthBirth
=
bir
.
get
(
Calendar
.
MONTH
);
int
dayBirth
=
bir
.
get
(
Calendar
.
DAY_OF_MONTH
);
// 大概年龄是当前年减去出生年
int
age
=
yearNow
-
yearBirth
;
// 如果出当前月大于出生月,或者当前月等于出生月但是当前日大于出生日,那么年龄age就加一岁
if
(
monthNow
>
monthBirth
||
(
monthNow
==
monthBirth
&&
dayNow
>
dayBirth
))
{
age
++;
int
age
;
// 如果当前月大于出生月,或者当前月等于出生月但是当前日大于出生日 直接减,否则再减1
if
((
monthBirth
<
monthNow
)
||
(
monthBirth
==
monthNow
&&
dayBirth
<
dayNow
))
{
age
=
yearNow
-
yearBirth
;
}
else
{
age
=
yearNow
-
yearBirth
-
1
;
}
return
age
;
}
...
...
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