java bigdecimal 格式化_Java DecimalFormat setParseBigDecimal()用法及代码示例

Java中DecimalFormat类的setParseBigDecimal()方法用于设置DecimalFormat类的parse()方法是否返回BigInteger类型的值。如果将此方法设置为true,则parse()方法将返回BigDecimal值。

用法:

public void setParseBigDecimal(boolean newValue)

参数:此方法接受布尔类型的单个参数newValue。如果将此值设置为true,则parse()方法将返回BigDecimal值。

返回值:此方法不返回任何值。

以下示例程序旨在说明上述方法:

程序1:

// Java program to illustrate the

// setParseBigDecimal() method

import java.text.DecimalFormat;

public class GFG {

public static void main(String[] args)

{

// Create a DecimalFormat instance

DecimalFormat deciFormat = new DecimalFormat();

deciFormat.setParseBigDecimal(true);

System.out.println(deciFormat.isParseBigDecimal());

}

}

输出:

true

程序2:

// Java program to illustrate the

// setParseBigDecimal() method

import java.text.DecimalFormat;

public class GFG {

public static void main(String[] args)

{

// Create a DecimalFormat instance

DecimalFormat deciFormat = new DecimalFormat();

deciFormat.setParseBigDecimal(false);

System.out.println(deciFormat.isParseBigDecimal());

}

}

输出:

false

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值