Date now = taskExecutionDate;
taskNextRunTime = task.getNextRunTime();
long delta = taskNextRunTime - now.getTime();
log.debug("now.getTime() = " + now.getTime() + ", " + now);
log.debug("taskNextRunTime = " + taskNextRunTime + ", " + new Date(taskNextRunTime));
log.debug("now.getTime() = " + now.getTime() + ", " + now);
log.debug("taskNextRunTime = " + taskNextRunTime + ", " + new Date(taskNextRunTime));
log.debug("delta = " + delta);
log.debug("endDate = " + task.getEndDate());
log.debug("startDate = " + task.getStartDate());
if(task.getEndDate().equals(task.getStartDate())){
taskNextRunTime = task.getNextRunTime();
log.debug("taskNextRunTime in = " + taskNextRunTime + ", " + new Date(taskNextRunTime));
}
我的日志文件显示了这个:
now.getTime() = 1440518657145, Tue Aug 25 12:04:17 EDT 2015
taskNextRunTime = 0, Wed Dec 31 19:00:00 EST 1969
delta = -1440518657145
endDate = Tue Aug 25 23:59:00 EDT 2015
startDate = Tue Aug 25 00:00:01 EDT 2015
我无法访问源代码task.class。我一直试图找到一个可以解决的问题但是还没有能力。我怎样才能在将来获得日期或是否有解决方法?任何帮助表示赞赏。
更新:Task.class方法:
public long getNextRunTime();
0 aload_0 [this]
1 invokestatic java.lang.System.currentTimeMillis() : long [24]
4 invokevirtual task.Task.getNextRunTime(long) : long [25]
7 lreturn
Line numbers:
[pc: 0, line: 239]
// Method descriptor #141 (J)J
// Stack: 4, Locals: 7
public long getNextRunTime(long arg0);
0 aload_0 [this]
1 invokevirtual task.Task.getEndDate() : java.util.Date [26]
4 ifnull 21
7 aload_0 [this]
8 invokevirtual task.Task.getEndDate() : java.util.Date [26]
11 invokevirtual java.util.Date.getTime() : long [27]
14 lload_1 [arg0]
15 lcmp
16 ifge 21
19 lconst_0
20 lreturn
21 aload_0 [this]
22 invokevirtual task.Task.getStartDate() : java.util.Date [28]
25 invokevirtual java.util.Date.getTime() : long [27]
28 lload_1 [arg0]
29 invokestatic java.lang.Math.max(long, long) : long [29]
32 lstore_3
33 aload_0 [this]
34 invokevirtual task.Task.getSchedule() : task.Schedule [30]
37 lload_3
38 aload_0 [this]
39 invokevirtual task.Task.getStartDate() : java.util.Date [28]
42 invokevirtual .task.Schedule.getNextRunTimeFrom(long, java.util.Date) : long [31]
45 lstore 5
47 aload_0 [this]
48 invokevirtual task.Task.getEndDate() : java.util.Date [26]
51 ifnull 69
54 aload_0 [this]
55 invokevirtual task.Task.getEndDate() : java.util.Date [26]
58 invokevirtual java.util.Date.getTime() : long [27]
61 lload 5
63 lcmp
64 ifge 69
67 lconst_0
68 lreturn
69 lload 5
71 lreturn
Line numbers:
[pc: 0, line: 251]
[pc: 19, line: 253]
[pc: 21, line: 258]
[pc: 33, line: 261]
[pc: 47, line: 265]
[pc: 67, line: 267]
[pc: 69, line: 270]
Stack map table: number of frames 2
[pc: 21, same]
[pc: 69, append: {long, long}]
我想要的输出是获取未来日期,即taskNextRunTime。每当用户在将来选择日期/时间时,它都会保存在taskNextRunTime中,但是当我检查我的日志时,它始终是taskNextRunTime = 0,Wed Dec 31 19:00:00 EST 1969. now.getTime工作正常,但是task.getNextRunTime()给了我12月31日19:00:00 EST 1969而不是将来选择的日期。