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


Java AmountFormatParams类代码示例

本文整理汇总了Java中org.javamoney.moneta.format.AmountFormatParams的典型用法代码示例。如果您正苦于以下问题:Java AmountFormatParams类的具体用法?Java AmountFormatParams怎么用?Java AmountFormatParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AmountFormatParams类属于org.javamoney.moneta.format包,在下文中一共展示了AmountFormatParams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import org.javamoney.moneta.format.AmountFormatParams; //导入依赖的package包/类
@Override
public void print(Appendable appendable, MonetaryAmount amount)
        throws IOException {
    if (amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class) == null ||
            amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class).length == 0) {
        appendable.append(this.formatFormat.format(amount.getNumber()
                .numberValue(BigDecimal.class)));
        return;
    }
    this.formatFormat.setGroupingUsed(false);
    String preformattedValue = this.formatFormat.format(amount.getNumber()
            .numberValue(BigDecimal.class));
    String[] numberParts = splitNumberParts(this.formatFormat,
            preformattedValue);
    if (numberParts.length != 2) {
        appendable.append(preformattedValue);
    } else {
        if (numberGroup==null) {
            char[] groupChars = amountFormatContext.get(AmountFormatParams.GROUPING_GROUPING_SEPARATORS, char[].class);
            if (groupChars == null || groupChars.length == 0) {
                groupChars = new char[]{this.formatFormat
                        .getDecimalFormatSymbols().getGroupingSeparator()};
            }
            int[] groupSizes = amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class);
            if (groupSizes == null) {
                groupSizes = new int[0];
            }
            numberGroup = new StringGrouper(groupChars, groupSizes);
        }
        preformattedValue = numberGroup.group(numberParts[0])
                + this.formatFormat.getDecimalFormatSymbols()
                .getDecimalSeparator() + numberParts[1];
        appendable.append(preformattedValue);
    }
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:36,代码来源:AmountNumberToken.java

示例2: print

import org.javamoney.moneta.format.AmountFormatParams; //导入依赖的package包/类
@Override
public void print(Appendable appendable, MonetaryAmount amount)
        throws IOException {
    if (amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class) == null ||
            amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class).length == 0) {
        appendable.append(this.formatFormat.format(amount.getNumber()
                .numberValue(BigDecimal.class)));
        return;
    }
    this.formatFormat.setGroupingUsed(false);
    String preformattedValue = this.formatFormat.format(amount.getNumber()
            .numberValue(BigDecimal.class));
    String[] numberParts = splitNumberParts(this.formatFormat,
            preformattedValue);
    if (numberParts.length != 2) {
        appendable.append(preformattedValue);
    } else {
        if (Objects.isNull(numberGroup)) {
            char[] groupChars = amountFormatContext.get(AmountFormatParams.GROUPING_GROUPING_SEPARATORS, char[].class);
            if (groupChars == null || groupChars.length == 0) {
                groupChars = new char[]{this.formatFormat
                        .getDecimalFormatSymbols().getGroupingSeparator()};
            }
            int[] groupSizes = amountFormatContext.get(AmountFormatParams.GROUPING_SIZES, int[].class);
            if (groupSizes == null) {
                groupSizes = new int[0];
            }
            numberGroup = new StringGrouper(groupChars, groupSizes);
        }
        preformattedValue = numberGroup.group(numberParts[0])
                + this.formatFormat.getDecimalFormatSymbols()
                .getDecimalSeparator() + numberParts[1];
        appendable.append(preformattedValue);
    }
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:36,代码来源:AmountNumberToken.java

示例3: main

import org.javamoney.moneta.format.AmountFormatParams; //导入依赖的package包/类
public static void main(String... args) {
    MonetaryAmount amt = Money.of(1234.5678, "EUR");
    System.out.println(amt.query(MonetaryFormats.getAmountFormat(Locale.GERMANY)));
    System.out.println(MonetaryFormats.getAmountFormat(Locale.GERMANY).format(amt));
    amt = Money.of(123412341234.5678, "INR");
    System.out.println(MonetaryFormats.getAmountFormat(new Locale("", "INR")).format(amt));

    // no with adaptive groupings
    System.out.println(MonetaryFormats.getAmountFormat(
            AmountFormatQueryBuilder.of(new Locale("", "INR"))
                    .set(AmountFormatParams.GROUPING_SIZES, new int[]{2, 3})
                    .set(AmountFormatParams.GROUPING_GROUPING_SEPARATORS, new char[]{',', '`'})
                    .build())
            .format(amt));
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:16,代码来源:FormattingAmounts.java


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