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
215add61
Commit
215add61
authored
Sep 07, 2023
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
漏提代码
parent
900dba91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
+28
-4
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+28
-4
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
215add61
...
@@ -6,8 +6,12 @@ import java.text.ParseException;
...
@@ -6,8 +6,12 @@ import java.text.ParseException;
import
java.text.ParsePosition
;
import
java.text.ParsePosition
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.TimeZone
;
/**
/**
* @description: 时间工具类
* @description: 时间工具类
* @author: DELL
* @author: DELL
...
@@ -623,7 +627,13 @@ public class DateUtils {
...
@@ -623,7 +627,13 @@ public class DateUtils {
// System.out.println(getQuarterStr(getMonth(dateParse("2021-5-11", null))));
// System.out.println(getQuarterStr(getMonth(dateParse("2021-5-11", null))));
// System.out.println(getWeekBeginDate(dateParse("2021-10-11", null)));
// System.out.println(getWeekBeginDate(dateParse("2021-10-11", null)));
// System.out.println(getWeekEndDate(dateParse("2021-10-11", null)));
// System.out.println(getWeekEndDate(dateParse("2021-10-11", null)));
System
.
out
.
println
(
secondsToTimeStr
(
3600
));
// System.out.println(secondsToTimeStr(3600));
// System.out.println(getTimeString(dateParse("2023-09-07 16:15:15", DATE_TIME_PATTERN), dateParse("2023-09-06 " +
// "16:15:15", DATE_TIME_PATTERN)));
long
diff
=
dateParse
(
"2022-09-07 16:16:16"
,
DATE_TIME_PATTERN
).
getTime
()
-
dateParse
(
"2023-09-06 10:15:15"
,
DATE_TIME_PATTERN
).
getTime
();
System
.
out
.
println
(
diff
/
1000
);
System
.
out
.
println
(
secondsToTimeStr
((
int
)
diff
/
1000
));
}
}
/**
/**
...
@@ -714,7 +724,7 @@ public class DateUtils {
...
@@ -714,7 +724,7 @@ public class DateUtils {
* @param oldTime 靠前时间
* @param oldTime 靠前时间
* @return
* @return
*/
*/
public
static
String
getTime
str
(
Date
newTime
,
Date
oldTime
)
{
public
static
String
getTime
String
(
Date
newTime
,
Date
oldTime
)
{
Long
newTimes
=
newTime
.
getTime
();
Long
newTimes
=
newTime
.
getTime
();
Long
oldTimes
=
oldTime
.
getTime
();
Long
oldTimes
=
oldTime
.
getTime
();
// 不改时间会多加八个小时
// 不改时间会多加八个小时
...
@@ -723,6 +733,20 @@ public class DateUtils {
...
@@ -723,6 +733,20 @@ public class DateUtils {
}
}
/**
/**
* 根据两个日期返回相差的时分秒
*
* @param newTime 靠后时间
* @param oldTime 靠前时间
* @return
*/
public
static
String
getTimeDiffString
(
Date
newTime
,
Date
oldTime
)
{
Long
newTimes
=
newTime
.
getTime
();
Long
oldTimes
=
oldTime
.
getTime
();
long
diff
=
newTimes
-
oldTimes
;
return
secondsToTimeStr
((
int
)
diff
/
1000
);
}
/**
* 获取现在日期字符串时间戳格式
* 获取现在日期字符串时间戳格式
*
*
* @return返回字符串格式 yyyyMMdd
* @return返回字符串格式 yyyyMMdd
...
...
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