本文整理汇总了Java中javax.money.MonetaryAmount.isZero方法的典型用法代码示例。如果您正苦于以下问题:Java MonetaryAmount.isZero方法的具体用法?Java MonetaryAmount.isZero怎么用?Java MonetaryAmount.isZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.money.MonetaryAmount
的用法示例。
在下文中一共展示了MonetaryAmount.isZero方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
public static void main(String[] args) {
CurrencyUnit currency = Monetary.getCurrency("BRL");
MonetaryAmount money = Money.of(10, currency);
MonetaryAmount money2 = Money.of(20, currency);
boolean equalsToResult = money.isEqualTo(money2);//false
boolean greaterThan = money.isGreaterThan(money2);//false
boolean greaterThanOrEqualTo = money.isGreaterThanOrEqualTo(money2);//false
boolean lessThan = money.isLessThan(money2);//true
boolean lessThanOrEqualTo = money.isLessThanOrEqualTo(money2);//true
boolean negative = money.isNegative();//false
boolean negativeOrZero = money.isNegativeOrZero();//false
boolean positive = money.isPositive();//true
boolean positiveOrZero = money.isPositiveOrZero();//true
boolean zero = money.isZero();//false
}
示例2: add
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public RoundedMoney add(MonetaryAmount amount) {
MoneyUtils.checkAmountParameter(amount, currency);
if (amount.isZero()) {
return this;
}
return new RoundedMoney(number.add(amount.getNumber().numberValue(BigDecimal.class)), currency,
rounding).with(rounding);
}
示例3: subtract
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public RoundedMoney subtract(MonetaryAmount subtrahend) {
MoneyUtils.checkAmountParameter(subtrahend, currency);
if (subtrahend.isZero()) {
return this;
}
MathContext mc = monetaryContext.get(MathContext.class);
if(mc==null){
mc = MathContext.DECIMAL64;
}
return new RoundedMoney(number.subtract(subtrahend.getNumber().numberValue(BigDecimal.class), mc),
currency, rounding);
}
示例4: add
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public Money add(MonetaryAmount amount) {
MoneyUtils.checkAmountParameter(amount, this.currency);
if (amount.isZero()) {
return this;
}
return new Money(this.number.add(amount.getNumber().numberValue(BigDecimal.class)), getCurrency());
}
示例5: subtract
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public Money subtract(MonetaryAmount subtrahend) {
MoneyUtils.checkAmountParameter(subtrahend, this.currency);
if (subtrahend.isZero()) {
return this;
}
return new Money(this.number.subtract(subtrahend.getNumber().numberValue(BigDecimal.class)), getCurrency());
}
示例6: add
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public FastMoney add(MonetaryAmount amount) {
checkAmountParameter(amount);
if (amount.isZero()) {
return this;
}
return new FastMoney(addExact(this.number, getInternalNumber(amount.getNumber(), false)), getCurrency());
}
示例7: subtract
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public FastMoney subtract(MonetaryAmount subtrahend) {
checkAmountParameter(subtrahend);
if (subtrahend.isZero()) {
return this;
}
return new FastMoney(subtractExact(this.number, getInternalNumber(subtrahend.getNumber(), false)),
getCurrency());
}