當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。