本文整理汇总了Java中javax.money.MonetaryAmount.toString方法的典型用法代码示例。如果您正苦于以下问题:Java MonetaryAmount.toString方法的具体用法?Java MonetaryAmount.toString怎么用?Java MonetaryAmount.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.money.MonetaryAmount
的用法示例。
在下文中一共展示了MonetaryAmount.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
public static void main(String[] args) {
CurrencyUnit currency = Monetary.getCurrency(Locale.US);
MonetaryAmount money = Money.of(10, currency);
MonetaryAmount money2 = FastMoney.of(20, currency);
MonetaryAmount money3 = RoundedMoney.of(30, currency, MonetaryOperators.rounding());
String text = money.toString();//USD 10
String text2 = money2.toString();//USD 20
String text3 = money3.toString();//USD 30
MonetaryAmount result = Money.parse(text);
MonetaryAmount result2 = FastMoney.parse(text2);
MonetaryAmount result3 = RoundedMoney.parse(text3);
}
示例2: queryFrom
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public String queryFrom(MonetaryAmount amount) {
if (amount==null) {
return null;
}
return amount.toString();
}
示例3: convertToDatabaseColumn
import javax.money.MonetaryAmount; //导入方法依赖的package包/类
@Override
public String convertToDatabaseColumn(MonetaryAmount monetaryAmount) {
return monetaryAmount.toString();
}