ProjectAres/PGM/src/main/java/tc/oc/pgm/utils/Strings.java

14 lines
433 B
Java
Raw Normal View History

2017-01-30 01:43:34 +01:00
package tc.oc.pgm.utils;
public abstract class Strings {
public static String progressPercentage(double completion) {
// This is probably the simplest way to get an accurate percentage while never rounding up to 100%
int percent = (int) Math.round(100.0 * completion);
if(percent == 100 && completion < 1d) {
return "99%";
} else {
return percent + "%";
}
}
}