|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.gentlyweb.utils.NumberUtils
public class NumberUtils
| Constructor Summary | |
|---|---|
NumberUtils()
|
|
| Method Summary | |
|---|---|
static long |
getDaysAsMillis(int days)
Given an int value treat it as a number of days and return the number of milliseconds for that number of days. |
static String |
getMillisAsFormattedSeconds(long millis)
Convert a number of milliseconds into seconds, we format to 2 decimal places, i.e. |
static double |
toPrecision(double v,
int digits)
Get the passed in double to the required precision. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NumberUtils()
| Method Detail |
|---|
public static double toPrecision(double v,
int digits)
digits
set to 2, in which case: 11.78 will be returned. This method
is useful when you want to round a number after a multiple
decimal place division.
In essence it merely rounds the decimal part to the required number of digits using Math.round.
This method is most useful when provided in a suitable wrapper, for instance:
public float getAsCurrency (float v)
{
return (float) GeneralUtils.toPrecision (v, 2);
}
Note, it is safe to pass 0 as either of the parameters, it should be noted
that passing 0 as digits has the same effect as calling: Math.round (v),
which makes sense since 0 digit precision of 11.77987 should be 12.
v - The value to round.digits - The number of decimal digits to round to.
public static long getDaysAsMillis(int days)
days - Number of days.
public static String getMillisAsFormattedSeconds(long millis)
millis - The milliseconds to format.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||