Number format solution with JsJava:
Number is often used in application logic.Many times we need display the number in the form of string which is user customed.For example,suppose we know a number 90700.87008.Perhaps you hope to display the number in the form of 9.07e+4.Perhaps you also hope to display the 0.5623 in the form of 56.2%.
All of above may be called number format.So how can we format a number in the customed form? To resove this propblem,we refer to DecimalFormat class in J2SE of Java language of Sun.
In the below,we quote the documentation of DecimalFormat class of J2SE of Sun.
Symbol Location Localized? Meaning 0Number Yes Digit #Number Yes Digit, zero shows as absent .Number Yes Decimal separator or monetary decimal separator -Number Yes Minus sign ,Number Yes Grouping separator ENumber Yes Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix. ;Subpattern boundary Yes Separates positive and negative subpatterns %Prefix or suffix Yes Multiply by 100 and show as percentage \u2030Prefix or suffix Yes Multiply by 1000 and show as per mille ¤(\u00A4)Prefix or suffix No Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator. 'Prefix or suffix No Used to quote special characters in a prefix or suffix, for example, "'#'#"formats 123 to"#123". To create a single quote itself, use two in a row:"# o''clock".
The usage of patterns in JsJava is similar to that in Java.But in jsjava2.0, "#" "," "'" "¡è" ";" are not supported.e.g as follows:
Use more,understand more!