improved formatTimemillis, some refactoring
This commit is contained in:
parent
844bb6e3b4
commit
6f1ef38ad5
@ -107,7 +107,6 @@ public class Scheduler extends Thread {
|
|||||||
long last_time_millis = System.currentTimeMillis();
|
long last_time_millis = System.currentTimeMillis();
|
||||||
double current_time_millis = 0.0;
|
double current_time_millis = 0.0;
|
||||||
|
|
||||||
|
|
||||||
long last_nanos = System.nanoTime();
|
long last_nanos = System.nanoTime();
|
||||||
double current_nanos = 0;
|
double current_nanos = 0;
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ public class Scheduler extends Thread {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public long currentTimeMillis1() {
|
private long currentTimeMillis1() {
|
||||||
|
|
||||||
long cur = System.nanoTime();
|
long cur = System.nanoTime();
|
||||||
long diff = cur - last_nanos;
|
long diff = cur - last_nanos;
|
||||||
@ -135,54 +134,20 @@ public class Scheduler extends Thread {
|
|||||||
return (long) this.current_time_millis;
|
return (long) this.current_time_millis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public long currentTimeMillis1_old() {
|
|
||||||
|
|
||||||
long cur_nano = System.nanoTime();
|
|
||||||
long diff_nano = cur_nano - last_nanos;
|
|
||||||
last_nanos = cur_nano;
|
|
||||||
|
|
||||||
long cur = System.currentTimeMillis();
|
|
||||||
|
|
||||||
long diff = (cur - last_time_millis);
|
|
||||||
|
|
||||||
//System.out.printf("Diff Nanos: %d Diff Millis %d, ND: %d\n", diff_nano, diff, diff_nano/1000000);
|
|
||||||
last_time_millis = cur;
|
|
||||||
|
|
||||||
// last_time_millis += diff;
|
|
||||||
//if (diff == 0) {
|
|
||||||
// diff++;
|
|
||||||
// }
|
|
||||||
if (pause) {
|
|
||||||
return (long) this.current_time_millis;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.cur_nano += (((double)diff_nano)/1000000.0)*this.acceleration;
|
|
||||||
// return (long)(cur_nano/1000000.0);
|
|
||||||
double fac = (((double) diff) + 10.0) * this.acceleration;
|
|
||||||
System.out.printf("Difdif: %f %f\n", fac, this.acceleration);
|
|
||||||
this.current_time_millis += ((double) diff) * this.acceleration;
|
|
||||||
return (long) this.current_time_millis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long currentTimeMillis() {
|
public long currentTimeMillis() {
|
||||||
// return (long)(cur_nano/1000000.0);
|
|
||||||
return (long) this.current_time_millis;
|
return (long) this.current_time_millis;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public String formatTimeMillis(long t) {
|
static public String formatTimeMillis(long t) {
|
||||||
Date date = new Date(t);
|
Date date = new Date(t);
|
||||||
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
// DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||||
String dateFormatted = formatter.format(date);
|
// String dateFormatted = formatter.format(date);
|
||||||
|
// return dateFormatted;
|
||||||
long seconds = (t / 1000) % 60;
|
long seconds = (t / 1000) % 60;
|
||||||
long minutes = (t / 1000 / 60) % 60;
|
long minutes = (t / 1000 / 60) % 60;
|
||||||
long hours = (t / 1000) / (60 * 60);
|
long hours = (t / 1000) / (60 * 60);
|
||||||
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
|
||||||
|
|
||||||
|
return String.format("%d:%02d:%02d", hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomicInteger nextTimerTask = new AtomicInteger(0);
|
AtomicInteger nextTimerTask = new AtomicInteger(0);
|
||||||
@ -293,7 +258,6 @@ public class Scheduler extends Thread {
|
|||||||
// if (evtime == null) {
|
// if (evtime == null) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
SortedSet<TimerTaskDef> s = event_queue.get(e.curevtime);
|
SortedSet<TimerTaskDef> s = event_queue.get(e.curevtime);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
// System.out.printf("My not found\n");
|
// System.out.printf("My not found\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user