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


Java CurrencyUnit.of方法代码示例

本文整理汇总了Java中org.joda.money.CurrencyUnit.of方法的典型用法代码示例。如果您正苦于以下问题:Java CurrencyUnit.of方法的具体用法?Java CurrencyUnit.of怎么用?Java CurrencyUnit.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.money.CurrencyUnit的用法示例。


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

示例1: getFormattedAmountByLocaleAndInvoiceCurrency

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static String getFormattedAmountByLocaleAndInvoiceCurrency(final BigDecimal amount, final String currencyCode, final Locale locale) {
    final CurrencyUnit currencyUnit = CurrencyUnit.of(currencyCode);

    final DecimalFormat numberFormatter = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
    final DecimalFormatSymbols dfs = numberFormatter.getDecimalFormatSymbols();
    dfs.setInternationalCurrencySymbol(currencyUnit.getCurrencyCode());

    try {
        final java.util.Currency currency = java.util.Currency.getInstance(currencyCode);
        dfs.setCurrencySymbol(currency.getSymbol(locale));
    } catch (final IllegalArgumentException e) {
        dfs.setCurrencySymbol(currencyUnit.getSymbol(locale));
    }

    numberFormatter.setDecimalFormatSymbols(dfs);
    numberFormatter.setMinimumFractionDigits(currencyUnit.getDefaultFractionDigits());
    numberFormatter.setMaximumFractionDigits(currencyUnit.getDefaultFractionDigits());

    return numberFormatter.format(amount.doubleValue());
}
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:21,代码来源:Formatter.java

示例2: NotificationItem

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public NotificationItem(final NotificationRequestItem notificationRequestItem) {
    this.additionalData = null;
    final Amount itemAmount = notificationRequestItem.getAmount();
    this.currency = (itemAmount == null ? null : itemAmount.getCurrency());
    if (this.currency != null && itemAmount.getValue() != null) {
        // The amount is in minor units
        final CurrencyUnit currencyUnit = CurrencyUnit.of(this.currency);
        this.amount = Money.ofMinor(currencyUnit, itemAmount.getValue()).getAmount();
    } else {
        this.amount = null;
    }
    this.eventCode = notificationRequestItem.getEventCode();
    this.eventDate = notificationRequestItem.getEventDate() == null ? null : new DateTime(notificationRequestItem.getEventDate().toGregorianCalendar().getTime());
    this.merchantAccountCode = notificationRequestItem.getMerchantAccountCode();
    this.merchantReference = notificationRequestItem.getMerchantReference();
    this.operations = notificationRequestItem.getOperations() == null ? null : notificationRequestItem.getOperations().getString();
    this.originalReference = notificationRequestItem.getOriginalReference();
    this.paymentMethod = notificationRequestItem.getPaymentMethod();
    this.pspReference = notificationRequestItem.getPspReference();
    this.reason = notificationRequestItem.getReason();
    this.success = notificationRequestItem.isSuccess();
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:23,代码来源:NotificationItem.java

示例3: applyConfiguration

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
public void applyConfiguration(SessionFactory sessionFactory) {

   	CurrencyUnitConfigured columnMapper = (CurrencyUnitConfigured) getColumnMapper();
   	if (currencyUnit == null) {

   		String currencyString = null;
		if (parameterValues != null) {
			currencyString = parameterValues.getProperty("currencyCode");
		}
		if (currencyString == null) {
			currencyString = ConfigurationHelper.getProperty("currencyCode");
		}
		if (currencyString != null) {

			currencyUnit = CurrencyUnit.of(currencyString);
		} else {
			throw new IllegalStateException(getClass().getSimpleName() + " requires currencyCode to be defined as a parameter, or the jadira.usertype.currencyCode Hibernate property to be defined");
		}
   	}
   	columnMapper.setCurrencyUnit(currencyUnit);
   }
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:23,代码来源:AbstractSingleColumnMoneyUserType.java

示例4: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static ClosingAvailableBalance of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_64), "unexpected field tag '%s'", field.getTag());

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    DebitCreditMark debitCreditMark = DebitCreditMark.ofFieldValue(subFields.get(0));
    LocalDate entryDate = LocalDate.parse(subFields.get(1), ENTRY_DATE_FORMATTER);
    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(2));
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(3));
    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new ClosingAvailableBalance(entryDate, debitCreditMark, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:14,代码来源:ClosingAvailableBalance.java

示例5: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static TransactionSummary of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_90D) || field.getTag().equals(FIELD_TAG_90C), "unexpected field tag '%s'", field.getTag());
    DebitCreditMark type = field.getTag().equals(FIELD_TAG_90D) ? DebitCreditMark.DEBIT : DebitCreditMark.CREDIT;

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    int transactionCount = Integer.parseInt(subFields.get(0));
    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(1));
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(2));
    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new TransactionSummary(type, transactionCount, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:14,代码来源:TransactionSummary.java

示例6: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static ClosingBalance of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_62F) || field.getTag().equals(FIELD_TAG_62M), "unexpected field tag '%s'", field.getTag());
    Type type = field.getTag().equals(FIELD_TAG_62F) ? Type.CLOSING : Type.INTERMEDIATE;

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    DebitCreditMark debitCreditMark = DebitCreditMark.ofFieldValue(subFields.get(0));
    LocalDate date = LocalDate.parse(subFields.get(1), DATE_FORMATTER);
    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(2));
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(3));
    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new ClosingBalance(type, date, debitCreditMark, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:15,代码来源:ClosingBalance.java

示例7: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static FloorLimitIndicator of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_34F), "unexpected field tag '%s'", field.getTag());

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(0));
    DebitCreditMark debitCreditMark = subFields.get(1) != null ? DebitCreditMark.ofFieldValue(subFields.get(1)) : null;
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(2));
    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new FloorLimitIndicator(debitCreditMark, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:13,代码来源:FloorLimitIndicator.java

示例8: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static OpeningBalance of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_60F) || field.getTag().equals(FIELD_TAG_60M), "unexpected field tag '%s'", field.getTag());
    Type type = field.getTag().equals(FIELD_TAG_60F) ? Type.OPENING : Type.INTERMEDIATE;

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    DebitCreditMark debitCreditMark = subFields.get(0) != null ? DebitCreditMark.ofFieldValue(subFields.get(0)) : null;
    LocalDate date = LocalDate.parse(subFields.get(1), DATE_FORMATTER);
    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(2));
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(3));
    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new OpeningBalance(type, date, debitCreditMark, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:15,代码来源:OpeningBalance.java

示例9: of

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
public static ForwardAvailableBalance of(GeneralField field) throws FieldNotationParseException {
    Preconditions.checkArgument(field.getTag().equals(FIELD_TAG_65), "unexpected field tag '%s'", field.getTag());

    List<String> subFields = SWIFT_NOTATION.parse(field.getContent());

    DebitCreditMark debitCreditMark = DebitCreditMark.ofFieldValue(subFields.get(0));
    LocalDate entryDate = LocalDate.parse(subFields.get(1), DATE_FORMATTER);
    CurrencyUnit amountCurrency = CurrencyUnit.of(subFields.get(2));
    BigDecimal amountValue = SwiftDecimalFormatter.parse(subFields.get(3));

    BigMoney amount = BigMoney.of(amountCurrency, amountValue);

    return new ForwardAvailableBalance(entryDate, debitCreditMark, amount);
}
 
开发者ID:qoomon,项目名称:banking-swift-messages-java,代码行数:15,代码来源:ForwardAvailableBalance.java

示例10: createTranslator

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
SimpleTranslator<CurrencyUnit, String> createTranslator() {
  return new SimpleTranslator<CurrencyUnit, String>(){
    @Override
    public CurrencyUnit loadValue(String datastoreValue) {
      return CurrencyUnit.of(datastoreValue);
    }

    @Override
    public String saveValue(CurrencyUnit pojoValue) {
      return pojoValue.toString();
    }};
}
 
开发者ID:google,项目名称:nomulus,代码行数:14,代码来源:CurrencyUnitTranslatorFactory.java

示例11: unmarshal

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
/** Parses a string into a {@link CurrencyUnit} object. */
@Override
public CurrencyUnit unmarshal(String currency) throws UnknownCurrencyException {
  try {
    return CurrencyUnit.of(nullToEmpty(currency).trim());
  } catch (IllegalArgumentException e) {
    throw new UnknownCurrencyException();
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:10,代码来源:CurrencyUnitAdapter.java

示例12: parseCreditsFromCsv

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
/**
 * Parses the provided CSV file of data from the auction provider and returns a multimap mapping
 * each registrar to the collection of auction credit amounts from this TLD's auctions that should
 * be awarded to this registrar, and validating that every credit amount's currency is in the
 * specified TLD-wide currency.
 */
private static ImmutableMultimap<Registrar, BigMoney> parseCreditsFromCsv(
    Path csvFile, String tld) throws IOException {
  List<String> lines = Files.readAllLines(csvFile, StandardCharsets.UTF_8);
  checkArgument(CsvHeader.getHeaders().equals(splitCsvLine(lines.get(0))),
      "Expected CSV header line not present");
  ImmutableMultimap.Builder<Registrar, BigMoney> builder = new ImmutableMultimap.Builder<>();
  for (String line : Iterables.skip(lines, 1)) {
    List<String> fields = splitCsvLine(line);
    checkArgument(CsvHeader.getHeaders().size() == fields.size(), "Wrong number of fields");
    try {
      String clientId = fields.get(CsvHeader.AFFILIATE.ordinal());
      Registrar registrar =
          checkArgumentPresent(
              Registrar.loadByClientId(clientId), "Registrar %s not found", clientId);
      CurrencyUnit tldCurrency = Registry.get(tld).getCurrency();
      CurrencyUnit currency = CurrencyUnit.of((fields.get(CsvHeader.CURRENCY_CODE.ordinal())));
      checkArgument(
          tldCurrency.equals(currency),
          "Credit in wrong currency (%s should be %s)",
          currency,
          tldCurrency);
      // We use BigDecimal and BigMoney to preserve fractional currency units when computing the
      // total amount of each credit (since auction credits are percentages of winning bids).
      BigDecimal creditAmount = new BigDecimal(fields.get(CsvHeader.COMMISSIONS.ordinal()));
      BigMoney credit = BigMoney.of(currency, creditAmount);
      builder.put(registrar, credit);
    } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
      throw new IllegalArgumentException("Error in line: " + line, e);
    }
  }
  return builder.build();
}
 
开发者ID:google,项目名称:nomulus,代码行数:39,代码来源:CreateAuctionCreditsCommand.java

示例13: fromNonNullString

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
public CurrencyUnit fromNonNullString(String s) {
	try {
		return CurrencyUnit.ofNumericCode(s);
	} catch (IllegalCurrencyException e) {
		return CurrencyUnit.of(s);
	}
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:9,代码来源:IntegerColumnCurrencyUnitMapper.java

示例14: parseKey

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
protected CurrencyUnit parseKey(String rawKey) {
  return CurrencyUnit.of(rawKey);
}
 
开发者ID:google,项目名称:nomulus,代码行数:5,代码来源:KeyValueMapParameter.java

示例15: deserialize

import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
CurrencyUnit deserialize(String jsonString) {
	return CurrencyUnit.of(jsonString);
}
 
开发者ID:cristhianescobar,项目名称:generator-android-starter,代码行数:4,代码来源:_CurrencyUnitTypeConverter.java


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