java命名空间java.text类decimalformat的类成员方法:
decimalformat定义及介绍
本文导语:
decimalformat
public decimalformat(string pattern,
decimalformatsymbols symbols)
使用给定的模式和符号创建一个 decimalformat。需要完全自定义格式化的行为时使用此构造方法。
要为给定的语言环境获取标准的格式,请对 numberf...
public decimalformat(string pattern,
decimalformatsymbols symbols)
- 使用给定的模式和符号创建一个 decimalformat。需要完全自定义格式化的行为时使用此构造方法。
要为给定的语言环境获取标准的格式,请对 numberformat 使用工厂方法,如 getinstance 或 getcurrencyinstance。如果只需为标准格式进行微小的调整,则可修改 numberformat 工厂方法所返回的格式。
- 参数:
pattern - 一个非本地化的模式字符串。symbols - 要使用的符号集
- 抛出:
nullpointerexception - 如果任意给定的参数为 null
illegalargumentexception - 如果给定的 pattern 无效- 另请参见:
numberformat.getinstance(),
numberformat.getnumberinstance(),
numberformat.getcurrencyinstance(),
numberformat.getpercentinstance(),
decimalformatsymbols
public final stringbuffer format(object number,
stringbuffer toappendto,
fieldposition pos)
- 格式化一个数,并将所得文本追加到给定的字符串缓冲区。该数可以是
number 的任意子类。
此实现使用所允许的最大精度。
- 覆盖:
- 类
numberformat 中的 format
- 参数:
number - 要格式化的数toappendto - 将格式化的文本所要追加到的 stringbufferpos - 在输入上:如果需要,是一个对齐字段。在输出上:对齐字段的偏移量。
- 返回:
- 以
toappendto 形式传入的值
- 抛出:
illegalargumentexception - 如果 number 为 null 或不是 number 的一个实例。
nullpointerexception - 如果 toappendto 或 pos 为 null
arithmeticexception - 如果需要使用设置为 roundingmode.unnecessary 的舍入模式进行舍入- 另请参见:
fieldposition