public class Formats
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
static java.lang.String |
formatDecimal(double value,
int dp) |
Turns a floating point value into a string with a given number of
decimal places using standard settings.
|
static java.lang.String |
formatDecimal(double value,
java.lang.String format) |
Turns a floating point value into a formatted string using standard
settings.
|
static java.lang.String |
formatDecimalLocal(double value,
int dp) |
Turns a floating point value into a string using current locale settings.
|
static java.lang.String |
formatDecimalLocal(double value,
java.lang.String format) |
Turns a floating point value into a formatted string using current
locale settings.
|
public static java.lang.String formatDecimal(double value, int dp)
value
- value to formatdp
- number of decimal places (digits after the decmal point)formatDecimal(PI,0) = "3."
, formatDecimal(0,10) = ".0000000000"
, formatDecimal(E*10,3) = "27.183"
public static java.lang.String formatDecimalLocal(double value, int dp)
formatDecimal
function.value
- value to formatdp
- number of decimal places (digits after the decmal point)formatDecimal(PI,0) = "3,"
, formatDecimal(0,10) = ",0000000000"
, formatDecimal(E*10,3) = "27,183"
public static java.lang.String formatDecimal(double value, java.lang.String format)
format
string is as defined by Java's
java.text.DecimalFormat
class.value
- value to formatformat
- format specifierformatDecimal(99, "#.000") = "99.000"
, formatDecimal(PI, "+0.##;-0.##") = "+3.14"
public static java.lang.String formatDecimalLocal(double value, java.lang.String format)
formatDecimal
function.value
- value to formatformat
- format specifierformatDecimal(99, "#.000") = "99,000"
, formatDecimal(PI, "+0.##;-0.##") = "+3,14"
Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.