public class MathUtils
extends java.lang.Object
Constructor and Description |
---|
MathUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
GetDownloadSpeedString(double averageSpeed)
Format for UI
|
static java.lang.String |
GetLengthString(long lengthInBytes)
Format file size for UI
|
static java.lang.String |
GetTimeRemainingOrDateString(long now,
long elapsed,
boolean bDate)
Similar to GetTimeRemainingString, but not only useful for ongoing tasks, as it will
display a date if the specified time range is more than 1 week
|
static java.lang.String |
GetTimeRemainingString(long timeRemainingMillis)
Get the amount of millis specified formatted for UI display of time remaining
for an ongoing task, or for an elapsed amount of time
|
static double |
log2(double v)
Implementation of base 2 logorithm using the straightforward unoptimized method of
log(x)/log(2).
|
static double |
parseDouble(java.lang.String value,
double defaultVal)
Convert a string to a double (exceptions caught)
|
static int |
parseInt(java.lang.String value,
int defaultVal)
Convert a string to an integer (exceptions caught)
|
static java.lang.String |
parseTimeRelativeToNow(java.lang.String timestamp)
Parse the ISO 8601 timestamp and format it relative now e.g.
|
public static java.lang.String GetLengthString(long lengthInBytes)
lengthInBytes
- the files size in bytespublic static java.lang.String GetTimeRemainingString(long timeRemainingMillis)
timeRemainingMillis
- the time representation in millisecondspublic static java.lang.String GetTimeRemainingOrDateString(long now, long elapsed, boolean bDate)
now
- time nowelapsed
- time to displaybDate
- true to display date for >1week, false to display "2 weeks ago"public static java.lang.String parseTimeRelativeToNow(java.lang.String timestamp)
timestamp
- the ISO 8601 timestamppublic static java.lang.String GetDownloadSpeedString(double averageSpeed)
averageSpeed
- bytes per millispublic static double log2(double v)
v
- the input value to used.public static double parseDouble(java.lang.String value, double defaultVal)
value
- String valuedefaultVal
- Default value if conversion failspublic static int parseInt(java.lang.String value, int defaultVal)
value
- String valuedefaultVal
- Default value if conversion fails