@Override public CurrencyUnit parse(String text, Locale locale) { return Monetary.getCurrency(text); }
@Override public CurrencyUnit parse(String text, Locale locale) { return Monetary.getCurrency(text); }
@Override public MonetaryAmount parse(String text, Locale locale) throws ParseException { CurrencyUnit currencyUnit = Monetary.getCurrency(locale); Number numberValue = this.numberFormatter.parse(text, locale); return Monetary.getDefaultAmountFactory().setNumber(numberValue).setCurrency(currencyUnit).create(); } }
@Override public MonetaryAmount parse(String text, Locale locale) throws ParseException { CurrencyStyleFormatter formatter = new CurrencyStyleFormatter(); Currency currency = determineCurrency(text, locale); CurrencyUnit currencyUnit = Monetary.getCurrency(currency.getCurrencyCode()); formatter.setCurrency(currency); formatter.setPattern(this.pattern); Number numberValue = formatter.parse(text, locale); return Monetary.getDefaultAmountFactory().setNumber(numberValue).setCurrency(currencyUnit).create(); }
@Override public MonetaryAmount parse(String text, Locale locale) throws ParseException { CurrencyUnit currencyUnit = Monetary.getCurrency(locale); Number numberValue = this.numberFormatter.parse(text, locale); return Monetary.getDefaultAmountFactory().setNumber(numberValue).setCurrency(currencyUnit).create(); } }
@Override public MonetaryAmount parse(String text, Locale locale) throws ParseException { CurrencyStyleFormatter formatter = new CurrencyStyleFormatter(); Currency currency = determineCurrency(text, locale); CurrencyUnit currencyUnit = Monetary.getCurrency(currency.getCurrencyCode()); formatter.setCurrency(currency); formatter.setPattern(this.pattern); Number numberValue = formatter.parse(text, locale); return Monetary.getDefaultAmountFactory().setNumber(numberValue).setCurrency(currencyUnit).create(); }
@Override public MonetaryAmountFactory setCurrency(String currencyCode) { this.currency = Monetary.getCurrency(currencyCode); return this; }
@Override public Money fromNonNullString(String s) { int separator = s.indexOf(' '); String currency = s.substring(0, separator); String value = s.substring(separator + 1); Monetary.getCurrency(currency); return Money.of(Long.parseLong(value), Monetary.getCurrency(currency)); }
@Override public FastMoney fromNonNullString(String s) { int separator = s.indexOf(' '); String currency = s.substring(0, separator); String value = s.substring(separator + 1); return FastMoney.of(Long.parseLong(value), Monetary.getCurrency(currency)); }
@Override public FastMoney fromNonNullString(String s) { int separator = s.indexOf(' '); String currency = s.substring(0, separator); String value = s.substring(separator + 1); return FastMoney.of(Long.parseLong(value), Monetary.getCurrency(currency)); }
@Override public Money fromNonNullString(String s) { int separator = s.indexOf(' '); String currency = s.substring(0, separator); String value = s.substring(separator + 1); return Money.of(Long.parseLong(value), Monetary.getCurrency(currency)); }
/** * Access a {@link CurrencyConversion} that can be applied as a * {@link MonetaryOperator} to an amount. * * @param termCode terminal/target currency code, not {@code null} * @return a new instance of a corresponding {@link CurrencyConversion}, * never {@code null}. * @throws MonetaryException if one of the currency codes passed is not valid. */ default CurrencyConversion getCurrencyConversion(String termCode){ return getCurrencyConversion(Monetary.getCurrency(termCode)); }
/** * Static factory method for creating a new instance of {@link Money}. * * @param currencyCode The target currency as ISO currency code. * @param number The numeric part, not null. * @param monetaryContext the {@link MonetaryContext} to be used, if {@code null} the * default {@link MonetaryContext} is used. * @return A new instance of {@link Money}. */ public static Money of(BigDecimal number, String currencyCode, MonetaryContext monetaryContext) { return new Money(number, Monetary.getCurrency(currencyCode), monetaryContext); }
@Override public Money fromNonNullString(String s) { int separator = s.indexOf(' '); String currency = s.substring(0, separator); String value = s.substring(separator + 1); return Money.of(Long.parseLong(value), Monetary.getCurrency(currency)); }
/** * Static factory method for creating a new instance of {@link RoundedMoney} . * * @param currencyCode The target currency as ISO currency code. * @param number The numeric part, not null. * @param rounding The rounding to be applied. * @return A new instance of {@link RoundedMoney}. */ public static RoundedMoney of(Number number, String currencyCode, MonetaryOperator rounding) { return new RoundedMoney(number, Monetary.getCurrency(currencyCode), rounding); }
@Override public void initialize(Currency currency) { List<CurrencyUnit> acceptedCurrencies = new ArrayList<CurrencyUnit>(); for ( String currencyCode : currency.value() ) { acceptedCurrencies.add( Monetary.getCurrency( currencyCode ) ); } this.acceptedCurrencies = CollectionHelper.toImmutableList( acceptedCurrencies ); }
@Override public boolean isAvailable(String baseCode, String termCode) { return isAvailable(ConversionQueryBuilder.of().setBaseCurrency(Monetary.getCurrency(baseCode)) .setTermCurrency(Monetary.getCurrency(termCode)).build()); }
@Override public ExchangeRate getExchangeRate(String baseCode, String termCode) { return getExchangeRate(ConversionQueryBuilder.of().setBaseCurrency(Monetary.getCurrency(baseCode)) .setTermCurrency(Monetary.getCurrency(termCode)).build()); }
@Override public MonetaryAmount decode(BsonReader reader, DecoderContext decoderContext) { reader.readStartDocument(); CurrencyUnit currency = Monetary.getCurrency(reader.readString(this.currencyKey)); BigDecimal number = new BigDecimal( BigInteger.valueOf(reader.readInt64(this.unscaledKey)), reader.readInt32(this.scaleKey)); reader.readEndDocument(); return Monetary.getDefaultAmountFactory().setNumber(number).setCurrency(currency) .create(); }
@Override public MonetaryAmount decode(BsonReader reader, DecoderContext decoderContext) { reader.readStartDocument(); CurrencyUnit currency = Monetary.getCurrency(reader.readString(this.currencyKey)); BigDecimal number = new BigDecimal(reader.readString(this.numberKey)); reader.readEndDocument(); return Monetary.getDefaultAmountFactory().setNumber(number).setCurrency(currency) .create(); }