power-time changes - 1 improvement + 1 bug fix
This commit is contained in:
parent
e5580d3f89
commit
abeeb87cbf
@ -42,6 +42,7 @@ public final class Duration {
|
|||||||
private static final String PLUS = "+";
|
private static final String PLUS = "+";
|
||||||
private static final String MINUS = "-";
|
private static final String MINUS = "-";
|
||||||
private static final String COLON = ":";
|
private static final String COLON = ":";
|
||||||
|
private static final String DOT = ".";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -275,7 +276,7 @@ public final class Duration {
|
|||||||
* @param string representing the new Duration
|
* @param string representing the new Duration
|
||||||
*/
|
*/
|
||||||
public Duration(String string) {
|
public Duration(String string) {
|
||||||
String[] splitString = string.split("\\:+");
|
String[] splitString = string.replace("\\.",":").split("\\:+");
|
||||||
if(splitString.length != 5) {
|
if(splitString.length != 5) {
|
||||||
throw new TimeException("Input String has wrong format.");
|
throw new TimeException("Input String has wrong format.");
|
||||||
}
|
}
|
||||||
@ -416,14 +417,14 @@ public final class Duration {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return StringUtils.appendObjects(this.isPositive() ? PLUS : MINUS,
|
return StringUtils.appendObjects(this.isPositive() ? PLUS : MINUS,
|
||||||
get(TimeUnit.DAY),
|
String.format("%02d", get(TimeUnit.DAY)),
|
||||||
COLON,
|
COLON,
|
||||||
get(TimeUnit.HOUR),
|
String.format("%02d", get(TimeUnit.HOUR)),
|
||||||
COLON,
|
COLON,
|
||||||
get(TimeUnit.MINUTE),
|
String.format("%02d", get(TimeUnit.MINUTE)),
|
||||||
COLON,
|
COLON,
|
||||||
get(TimeUnit.SECOND),
|
String.format("%02d", get(TimeUnit.SECOND)),
|
||||||
COLON,
|
DOT,
|
||||||
get(TimeUnit.MILLISECOND));
|
String.format("%03d", get(TimeUnit.MILLISECOND)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,8 @@ public class RemainingTimeCalculator {
|
|||||||
|
|
||||||
public long remainingSecondsUntilEnd() {
|
public long remainingSecondsUntilEnd() {
|
||||||
long remains = this.total - this.done;
|
long remains = this.total - this.done;
|
||||||
long remainsSeconds = (this.elapsedSecondSinceStart() / this.done) * remains;
|
double elapsedSecondSinceStartDouble = (double) elapsedSecondSinceStart();
|
||||||
|
long remainsSeconds = (long)((elapsedSecondSinceStartDouble / ((double)this.done)) * remains);
|
||||||
return remainsSeconds;
|
return remainsSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user