私はBlackberry RIM APIを使用して非常に簡単なことをしようとしています - 私は1000000
フォーマットしたい文字列を持っています1,000,000.00
それを行うために 2 つの RIM API クラスを試しましたが、実際に必要なものはどれもありませんでした。
1) javax.microedition.global.Formatter
String value = "1000000";
float floatValue = Float.parseFloat(value);
Formatter f = new Formatter(); //also tried with locale specified - Formatter("en")
String result = f.formatNumber(floatValue, 2);
結果変数は次の1000000.00
とおりです。小数点記号はありますが、グループ区切り記号 (コンマ) がありません。
2) net.rim.device.api.i18n.MessageFormat (Java の標準版の java.text.MessageFormat と互換性があると主張)
String value = "1000000";
Object[] objs = {value};
MessageFormat mfPlain = new MessageFormat("{0}");
MessageFormat mfWithFormat = new MessageFormat("{0,number,###,###.##}");
String result1 = mfPlain.format(objs);
String result2 = mfWithFormat.format(objs);
result1: (mfWithFormat
コードがコメントアウトされている場合) 単純な結果が得られます1000000
(予想どおりですが、役に立ちません)。結果 2: スローしIllegalArgumentException
ます。
この時点で、次に何を試すかの選択肢がありません...
助言がありますか?