当前位置: 首页>>代码示例>>Java>>正文


Java MonetaryQueries类代码示例

本文整理汇总了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()
        )));
    }
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:19,代码来源:AmountsUseExtensionPoints.java

示例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

}
 
开发者ID:otaviojava,项目名称:money-api-book-samples,代码行数:10,代码来源:MonetaryQueriesExample.java

示例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();
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:8,代码来源:LongColumnFastMoneyMajorMapper.java

示例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() };
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:6,代码来源:PersistentFastMoneyMajorAmountAndCurrency.java


注:本文中的org.javamoney.moneta.function.MonetaryQueries类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。