Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6dc6ddac
authored
Nov 30, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:时间返回优化
1 parent
3ec3f5eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
72 deletions
project-order/src/main/java/com/dituhui/pea/order/common/TimeUtils.java
project-order/src/main/java/com/dituhui/pea/order/dto/OrderServiceDetailResp.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceDetailImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/TimeUtils.java
View file @
6dc6dda
package
com
.
dituhui
.
pea
.
order
.
common
;
import
cn.hutool.core.util.ObjectUtil
;
import
java.sql.Timestamp
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
...
...
@@ -7,68 +9,71 @@ import java.time.LocalTime;
import
java.time.format.DateTimeFormatter
;
public
class
TimeUtils
{
public
static
final
String
DATE_TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
DATE_NO_GAP_FORMAT
=
"yyyyMMdd"
;
public
static
final
String
DATE_GAP_FORMAT
=
"yyyy-MM-dd"
;
public
static
final
String
TIME_HH_MM_FORMAT
=
"HH:mm"
;
public
static
final
String
IsoTimestamp2DateTime
(
Timestamp
timestamp
)
{
// Timestamp转换为日期时间字符串
LocalDateTime
localDateTime
=
timestamp
.
toLocalDateTime
();
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
Timestamp
IsoDateTime2Timestamp
(
String
datetime
)
{
// 将日期时间字符串转换为Timestamp
LocalDateTime
localDateTime
=
LocalDateTime
.
parse
(
datetime
,
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
return
Timestamp
.
valueOf
(
localDateTime
);
}
public
static
final
String
timestamp2DateTime
(
Timestamp
timestamp
,
String
pattern
)
{
// Timestamp转换为日期时间字符串
LocalDateTime
localDateTime
=
timestamp
.
toLocalDateTime
();
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
Timestamp
dateTime2Timestamp
(
String
datetime
,
String
pattern
)
{
// 将日期时间字符串转换为Timestamp
LocalDateTime
localDateTime
=
LocalDateTime
.
parse
(
datetime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Timestamp
.
valueOf
(
localDateTime
);
}
public
static
final
LocalDate
IsoDate2LocalDate
(
String
s
)
{
return
LocalDate
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
DATE_GAP_FORMAT
));
}
public
static
final
LocalDate
date2LocalDate
(
String
s
,
String
pattern
)
{
return
LocalDate
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
LocalDateTime
IsoDateTime2LocalDateTime
(
String
s
)
{
return
LocalDateTime
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
String
IsoLocalDateTime2String
(
LocalDateTime
localDateTime
)
{
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
String
localDateTime2String
(
LocalDateTime
localDateTime
,
String
pattern
)
{
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
String
IsoLocalDate2String
(
LocalDate
localDate
)
{
return
localDate
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_GAP_FORMAT
));
}
public
static
final
LocalTime
time2LocalTime
(
String
s
)
{
return
LocalTime
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
TIME_HH_MM_FORMAT
));
}
public
static
final
LocalDate
addDays
(
LocalDate
date
,
long
days
)
{
return
date
.
plusDays
(
days
);
}
public
static
final
LocalDate
subDays
(
LocalDate
date
,
long
days
)
{
return
date
.
minusDays
(
days
);
}
public
static
final
String
DATE_TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
DATE_NO_GAP_FORMAT
=
"yyyyMMdd"
;
public
static
final
String
DATE_GAP_FORMAT
=
"yyyy-MM-dd"
;
public
static
final
String
TIME_HH_MM_FORMAT
=
"HH:mm"
;
public
static
final
String
IsoTimestamp2DateTime
(
Timestamp
timestamp
)
{
// Timestamp转换为日期时间字符串
LocalDateTime
localDateTime
=
timestamp
.
toLocalDateTime
();
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
Timestamp
IsoDateTime2Timestamp
(
String
datetime
)
{
// 将日期时间字符串转换为Timestamp
LocalDateTime
localDateTime
=
LocalDateTime
.
parse
(
datetime
,
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
return
Timestamp
.
valueOf
(
localDateTime
);
}
public
static
final
String
timestamp2DateTime
(
Timestamp
timestamp
,
String
pattern
)
{
// Timestamp转换为日期时间字符串
LocalDateTime
localDateTime
=
timestamp
.
toLocalDateTime
();
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
Timestamp
dateTime2Timestamp
(
String
datetime
,
String
pattern
)
{
// 将日期时间字符串转换为Timestamp
LocalDateTime
localDateTime
=
LocalDateTime
.
parse
(
datetime
,
DateTimeFormatter
.
ofPattern
(
pattern
));
return
Timestamp
.
valueOf
(
localDateTime
);
}
public
static
final
LocalDate
IsoDate2LocalDate
(
String
s
)
{
return
LocalDate
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
DATE_GAP_FORMAT
));
}
public
static
final
LocalDate
date2LocalDate
(
String
s
,
String
pattern
)
{
return
LocalDate
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
LocalDateTime
IsoDateTime2LocalDateTime
(
String
s
)
{
return
LocalDateTime
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
String
IsoLocalDateTime2String
(
LocalDateTime
localDateTime
)
{
if
(
ObjectUtil
.
isNull
(
localDateTime
))
{
return
null
;
}
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_TIME_FORMAT
));
}
public
static
final
String
localDateTime2String
(
LocalDateTime
localDateTime
,
String
pattern
)
{
return
localDateTime
.
format
(
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
final
String
IsoLocalDate2String
(
LocalDate
localDate
)
{
return
localDate
.
format
(
DateTimeFormatter
.
ofPattern
(
DATE_GAP_FORMAT
));
}
public
static
final
LocalTime
time2LocalTime
(
String
s
)
{
return
LocalTime
.
parse
(
s
,
DateTimeFormatter
.
ofPattern
(
TIME_HH_MM_FORMAT
));
}
public
static
final
LocalDate
addDays
(
LocalDate
date
,
long
days
)
{
return
date
.
plusDays
(
days
);
}
public
static
final
LocalDate
subDays
(
LocalDate
date
,
long
days
)
{
return
date
.
minusDays
(
days
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/OrderServiceDetailResp.java
View file @
6dc6dda
...
...
@@ -113,22 +113,22 @@ public class OrderServiceDetailResp {
/**
* 计划开始时间
*/
private
LocalDateTime
planStartTime
;
private
String
planStartTime
;
/**
* 计划结束时间
*/
private
LocalDateTime
planEndTime
;
private
String
planEndTime
;
/**
* 开始服务时间
*/
private
LocalDateTime
actualStartTime
;
private
String
actualStartTime
;
/**
* 结束服务时间
*/
private
LocalDateTime
actualEndTime
;
private
String
actualEndTime
;
//
// @Data
// @JsonInclude(JsonInclude.Include.NON_NULL)
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceDetailImpl.java
View file @
6dc6dda
...
...
@@ -117,10 +117,10 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res
.
setBeanTags
(
order
.
getBeanTags
());
res
.
setTranscend
(
order
.
getTranscend
());
res
.
setEngineerCodeSub
(
order
.
getEngineerCodeSub
());
res
.
setPlanStartTime
(
order
.
getPlanStartTime
(
));
res
.
setPlanEndTime
(
order
.
getPlanEndTime
(
));
res
.
setActualStartTime
(
order
.
getActualStartTime
(
));
res
.
setActualEndTime
(
order
.
getActualEndTime
(
));
res
.
setPlanStartTime
(
TimeUtils
.
IsoLocalDateTime2String
(
order
.
getPlanStartTime
()
));
res
.
setPlanEndTime
(
TimeUtils
.
IsoLocalDateTime2String
(
order
.
getPlanEndTime
()
));
res
.
setActualStartTime
(
TimeUtils
.
IsoLocalDateTime2String
(
order
.
getActualStartTime
()
));
res
.
setActualEndTime
(
TimeUtils
.
IsoLocalDateTime2String
(
order
.
getActualEndTime
()
));
return
Result
.
success
(
res
);
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment