Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
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 459b5dcf
authored
Apr 02, 2022
by
邓敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时器位数计算不足问题修复
1 parent
c4adc855
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
src/main/java/com/subsidy/util/QuartzUtil.java
src/main/java/com/subsidy/util/QuartzUtil.java
View file @
459b5dc
...
...
@@ -27,6 +27,10 @@ public class QuartzUtil {
@Autowired
private
Scheduler
scheduler
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
DateFormatUtil
.
parse
(
"2022-06-28 11:30:47"
,
"yyyy-MM-dd HH:mm:ss"
).
getTime
()
-
System
.
currentTimeMillis
());
}
/**
* 添加定时任务,只执行一次的定时任务
*
...
...
@@ -41,7 +45,7 @@ public class QuartzUtil {
JobKey
key
=
new
JobKey
(
name
,
group
);
List
<
Trigger
>
triggers
=
(
List
<
Trigger
>)
scheduler
.
getTriggersOfJob
(
key
);
if
(
triggers
.
size
()
==
0
)
{
int
time
=
(
int
)
(
date
.
getTime
()
-
System
.
currentTimeMillis
())
/
1000
;
Long
time
=
(
date
.
getTime
()
-
System
.
currentTimeMillis
())
/
1000
;
JobDataMap
jobDataMap
=
new
JobDataMap
();
jobDataMap
.
put
(
"params"
,
params
);
JobDetail
jobDetail
=
JobBuilder
.
newJob
(
cls
)
...
...
@@ -50,7 +54,7 @@ public class QuartzUtil {
.
build
();
SimpleTrigger
trigger
=
(
SimpleTrigger
)
TriggerBuilder
.
newTrigger
()
.
withIdentity
(
name
,
group
)
.
startAt
(
futureDate
(
time
,
DateBuilder
.
IntervalUnit
.
SECOND
))
.
startAt
(
futureDate
(
Math
.
toIntExact
(
time
)
,
DateBuilder
.
IntervalUnit
.
SECOND
))
.
build
();
scheduler
.
scheduleJob
(
jobDetail
,
trigger
);
if
(!
scheduler
.
isShutdown
())
{
...
...
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