parent
63c73abedd
commit
b8bfe0c52c
|
@ -40,13 +40,26 @@ public class TimePlotLabeler implements PlotLabeler{
|
|||
int hour, minute, second, millisecond;
|
||||
hour = (int)(pos / 3600);
|
||||
minute = ((int)(pos / 60) % 60);
|
||||
second = (int)Math.round(pos) % 60;
|
||||
second = (int)(pos * 1) % 60;
|
||||
millisecond = (int)(pos * 1000) % 1000;
|
||||
String sh, sm, ss, sms;
|
||||
sh = hour < 10? String.format("0%d", hour) : String.format("%d", hour);
|
||||
sm = minute < 10? String.format("0%d", minute) : String.format("%d", minute);
|
||||
ss = second < 10? String.format("0%d", second) : String.format("%d", second);
|
||||
sms = millisecond < 10? String.format("0%d", millisecond) : String.format("%d", millisecond);
|
||||
sms = millisecond < 10? String.format("00%d", millisecond) : millisecond < 100? String.format("0%d", millisecond) : String.format("%d", millisecond);
|
||||
return sh + ":" + sm + ":" + ss + "." + sms;
|
||||
}
|
||||
|
||||
public static Double stringToDoubleSec(String stringTime) {
|
||||
double ret = 0;
|
||||
String val = stringTime.substring(0, 2);
|
||||
ret = Double.parseDouble(val) * 3600.0; //hour
|
||||
val = stringTime.substring(3,5);
|
||||
ret += Double.parseDouble(val) * 60.0; //minutes
|
||||
val = stringTime.substring(6,8);
|
||||
ret += Double.parseDouble(val); //seconds
|
||||
val = stringTime.substring(9,12);
|
||||
ret += Double.parseDouble(val) / 1000.0; //milliseconds
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue