本文整理汇总了Java中org.javamoney.moneta.function.MonetaryQueries类的典型用法代码示例。如果您正苦于以下问题:Java MonetaryQueries类的具体用法?Java MonetaryQueries怎么用?Java MonetaryQueries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MonetaryQueries类属于org.javamoney.moneta.function包,在下文中一共展示了MonetaryQueries类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.javamoney.moneta.function.MonetaryQueries; //导入依赖的package包/类
public static void main(String... args){
MonetaryAmount amt = Money.of(1234.56234, "CHF");
ConsoleUtils.printDetails("Base", amt);
ConsoleUtils.printDetails("10.5 %", amt.with(MonetaryOperators.percent(10.5)));
ConsoleUtils.printDetails("10.5 o/oo", amt.with(MonetaryOperators.permil(10.5)));
ConsoleUtils.printDetails("Major Part", amt.with(MonetaryOperators.majorPart()));
ConsoleUtils.printDetails("Minor Part", amt.with(MonetaryOperators.minorPart()));
ConsoleUtils.printDetails("1/Base (Reciprocal)", amt.with(MonetaryOperators.reciprocal()));
System.out.println("Minor Part as long -> " + amt.query(MonetaryQueries.extractMinorPart()));
System.out.println("Major Part as long -> " + amt.query(MonetaryQueries.extractMajorPart()));
ConsoleUtils.printDetails("Rounded (default)", amt.with(Monetary.getDefaultRounding()));
ConsoleUtils.printDetails("Rounded (DOWN, 1 fraction digit)", amt.with(Monetary.getRounding(
RoundingQueryBuilder.of().set(RoundingMode.DOWN).setScale(1).build()
)));
}
示例2: main
import org.javamoney.moneta.function.MonetaryQueries; //导入依赖的package包/类
public static void main(String[] args) {
CurrencyUnit currency = Monetary.getCurrency(Locale.US);
MonetaryAmount money = Money.of(120.23, currency);
Long moneyInCents = money.query(MonetaryQueries.convertMinorPart());//12023
Long majorPart = money.query(MonetaryQueries.extractMajorPart());//120
Long minorPart = money.query(MonetaryQueries.extractMinorPart());//23
}
示例3: toNonNullValue
import org.javamoney.moneta.function.MonetaryQueries; //导入依赖的package包/类
@Override
public Long toNonNullValue(MonetaryAmount value) {
if (!currencyUnit.equals(value.getCurrency())) {
throw new IllegalStateException("Expected currency " + currencyUnit.getCurrencyCode() + " but was " + value.getCurrency());
}
return MonetaryQueries.extractMajorPart().queryFrom(value).longValue();
}
示例4: toConvertedColumns
import org.javamoney.moneta.function.MonetaryQueries; //导入依赖的package包/类
@Override
protected Object[] toConvertedColumns(MonetaryAmount value) {
return new Object[] { value.getCurrency(), MonetaryQueries.extractMajorPart().queryFrom(value).longValue() };
}