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
cb104fa0
Commit
cb104fa0
authored
Jul 18, 2022
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合同优化-年月差值
parent
556a631f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
DateUtil.java
...om/yifu.cloud.plus.v1/yifu/common/core/util/DateUtil.java
+6
-3
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/util/DateUtil.java
View file @
cb104fa0
...
...
@@ -861,15 +861,18 @@ public class DateUtil {
/**
* @param startDate
* @param endDate
* @Description: 计算年月的月份差值(202205-202205=0
)想要1自己+1
* @Description: 计算年月的月份差值(202205-202205=0
,202205-202105=12)想要1自己+1 年月差值
* @Author: hgw
* @Date: 2022/7/15 12:16
* @return: int
**/
public
static
int
getMonthDiff
(
Date
startDate
,
Date
endDate
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
DATETIME_YYYYMM
);
return
Integer
.
parseInt
(
sdf
.
format
(
endDate
))
-
Integer
.
parseInt
(
sdf
.
format
(
startDate
));
Calendar
c1
=
Calendar
.
getInstance
();
Calendar
c2
=
Calendar
.
getInstance
();
c1
.
setTime
(
startDate
);
c2
.
setTime
(
endDate
);
return
12
*
(
c2
.
get
(
Calendar
.
YEAR
)
-
c1
.
get
(
Calendar
.
YEAR
))
+
c2
.
get
(
Calendar
.
MONTH
)
-
c1
.
get
(
Calendar
.
MONTH
);
}
catch
(
IllegalFormatException
e
)
{
log
.
error
(
"计算日期月份差,方法名:getMonthDiff,出错:"
,
e
);
return
0
;
...
...
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