本文整理汇总了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());
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}};
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例14: parseKey
import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
@Override
protected CurrencyUnit parseKey(String rawKey) {
return CurrencyUnit.of(rawKey);
}
示例15: deserialize
import org.joda.money.CurrencyUnit; //导入方法依赖的package包/类
CurrencyUnit deserialize(String jsonString) {
return CurrencyUnit.of(jsonString);
}