CustAcctMsgDelayTask.java
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.zteits.pay.domain;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
public class CustAcctMsgDelayTask implements Delayed{
private String custId;
private long timeOut;
/**
* 到期时间,单位是秒
*/
public CustAcctMsgDelayTask(String custId,long timeoutSeconds) {
this.timeOut = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(timeoutSeconds, TimeUnit.SECONDS);
this.custId = custId;
}
@Override
public int compareTo(Delayed d) {
return (int) (this.getDelay(TimeUnit.MILLISECONDS) - d.getDelay(TimeUnit.MILLISECONDS));
}
@Override
public long getDelay(TimeUnit unit) {
return unit.convert(this.timeOut - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
}
public String getCustId() {
return custId;
}
public void setCustId(String custId) {
this.custId = custId;
}
public long getTimeOut() {
return timeOut;
}
public void setTimeOut(long timeOut) {
this.timeOut = timeOut;
}
}