14 lines
433 B
Java
14 lines
433 B
Java
|
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 + "%";
|
||
|
}
|
||
|
}
|
||
|
}
|