org.bitcoinj.utils.Fiat Java Examples
The following examples show how to use
org.bitcoinj.utils.Fiat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmountFields.java From GreenBits with GNU General Public License v3.0 | 6 votes |
private void convertFiatToBtc() { if (mConverting || mIsPausing) return; mConverting = true; if (mService.isElements()) { // fiat == btc in elements mAmountEdit.setText(UI.getText(mAmountFiatEdit)); finishConversion(); return; } try { final Fiat fiatValue = Fiat.parseFiat("???", UI.getText(mAmountFiatEdit)); mAmountEdit.setText(UI.formatCoinValue(mService, mService.getFiatRate().fiatToCoin(fiatValue))); } catch (final ArithmeticException | IllegalArgumentException e) { UI.clear(mAmountEdit); } finishConversion(); }
Example #2
Source File: FormattingUtils.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
public static String formatFiat(Fiat fiat, MonetaryFormat format, boolean appendCurrencyCode) { if (fiat != null) { try { final String res = format.noCode().format(fiat).toString(); if (appendCurrencyCode) return res + " " + fiat.getCurrencyCode(); else return res; } catch (Throwable t) { log.warn("Exception at formatFiatWithCode: " + t.toString()); return Res.get("shared.na") + " " + fiat.getCurrencyCode(); } } else { return Res.get("shared.na"); } }
Example #3
Source File: BSFormatter.java From bisq-core with GNU Affero General Public License v3.0 | 6 votes |
public String formatFiat(Fiat fiat, MonetaryFormat format, boolean appendCurrencyCode) { if (fiat != null) { try { final String res = format.noCode().format(fiat).toString(); if (appendCurrencyCode) return res + " " + fiat.getCurrencyCode(); else return res; } catch (Throwable t) { log.warn("Exception at formatFiatWithCode: " + t.toString()); return Res.get("shared.na") + " " + fiat.getCurrencyCode(); } } else { return Res.get("shared.na"); } }
Example #4
Source File: GUIUtil.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
public static String getBsqInUsd(Price bsqPrice, Coin bsqAmount, PriceFeedService priceFeedService, BsqFormatter bsqFormatter) { MarketPrice usdMarketPrice = priceFeedService.getMarketPrice("USD"); if (usdMarketPrice == null) { return Res.get("shared.na"); } long usdMarketPriceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(usdMarketPrice.getPrice(), Fiat.SMALLEST_UNIT_EXPONENT)); Price usdPrice = Price.valueOf("USD", usdMarketPriceAsLong); String bsqAmountAsString = bsqFormatter.formatCoin(bsqAmount); Volume bsqAmountAsVolume = Volume.parse(bsqAmountAsString, "BSQ"); Coin requiredBtc = bsqPrice.getAmountByVolume(bsqAmountAsVolume); Volume volumeByAmount = usdPrice.getVolumeByAmount(requiredBtc); return DisplayUtils.formatAverageVolumeWithCode(volumeByAmount); }
Example #5
Source File: PriceAlert.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void update() { if (user.getPriceAlertFilter() != null) { PriceAlertFilter filter = user.getPriceAlertFilter(); String currencyCode = filter.getCurrencyCode(); MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode); if (marketPrice != null) { int exp = CurrencyUtil.isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT; double priceAsDouble = marketPrice.getPrice(); long priceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(priceAsDouble, exp)); String currencyName = CurrencyUtil.getNameByCode(currencyCode); if (priceAsLong > filter.getHigh() || priceAsLong < filter.getLow()) { String msg = Res.get("account.notifications.priceAlert.message.msg", currencyName, FormattingUtils.formatMarketPrice(priceAsDouble, currencyCode), CurrencyUtil.getCurrencyPair(currencyCode)); MobileMessage message = new MobileMessage(Res.get("account.notifications.priceAlert.message.title", currencyName), msg, MobileMessageType.PRICE); log.error(msg); try { mobileNotificationService.sendMessage(message); // If an alert got triggered we remove the filter. user.removePriceAlertFilter(); } catch (Exception e) { log.error(e.toString()); e.printStackTrace(); } } } } }
Example #6
Source File: GaService.java From GreenBits with GNU General Public License v3.0 | 5 votes |
public String coinToFiat(final Coin btcValue) { if (!hasFiatRate()) return "N/A"; Fiat fiatValue = getFiatRate().coinToFiat(btcValue); // strip extra decimals (over 2 places) because that's what the old JS client does fiatValue = fiatValue.subtract(fiatValue.divideAndRemainder((long) Math.pow(10, Fiat.SMALLEST_UNIT_EXPONENT - 2))[1]); return MonetaryFormat.FIAT.minDecimals(2).noCode().format(fiatValue).toString(); }
Example #7
Source File: GaService.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private Coin getSpendingLimitAmount() { final Coin unconverted = mLimitsData.getCoin("total"); if (isElements()) return unconverted.multiply(100); if (!mLimitsData.getBool("is_fiat")) return unconverted; // Fiat class uses SMALLEST_UNIT_EXPONENT units (10^4), our limit is // held in 10^2 (e.g. cents) units, hence we * 100 below. final Fiat fiatLimit = Fiat.valueOf("???", mLimitsData.getLong("total") * 100); return getFiatRate().fiatToCoin(fiatLimit); }
Example #8
Source File: Exchanger.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private double convertBtcToFiat(final Coin btcValue) { try { Fiat fiatValue = mService.getFiatRate().coinToFiat(btcValue); // strip extra decimals (over 2 places) because that's what the old JS client does fiatValue = fiatValue.subtract(fiatValue.divideAndRemainder((long) Math.pow(10, Fiat.SMALLEST_UNIT_EXPONENT - 2))[1]); return Double.valueOf(fiatValue.toPlainString()); } catch (final ArithmeticException | IllegalArgumentException e) { return -1; } }
Example #9
Source File: WalletTest.java From GreenBits with GNU General Public License v3.0 | 5 votes |
@Test public void sendRequestExchangeRate() throws Exception { receiveATransaction(wallet, myAddress); SendRequest sendRequest = SendRequest.to(myAddress, Coin.COIN); sendRequest.exchangeRate = new ExchangeRate(Fiat.parseFiat("EUR", "500")); wallet.completeTx(sendRequest); assertEquals(sendRequest.exchangeRate, sendRequest.tx.getExchangeRate()); }
Example #10
Source File: BsqDashboardView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private long getUSDAverage(List<TradeStatistics2> bsqList, List<TradeStatistics2> usdList) { // Use next USD/BTC print as price to calculate BSQ/USD rate // Store each trade as amount of USD and amount of BSQ traded List<Tuple2<Double, Double>> usdBsqList = new ArrayList<>(bsqList.size()); usdList.sort(Comparator.comparing(o -> o.getTradeDate().getTime())); var usdBTCPrice = 10000d; // Default to 10000 USD per BTC if there is no USD feed at all for (TradeStatistics2 item : bsqList) { // Find usdprice for trade item usdBTCPrice = usdList.stream() .filter(usd -> usd.getTradeDate().getTime() > item.getTradeDate().getTime()) .map(usd -> MathUtils.scaleDownByPowerOf10((double) usd.getTradePrice().getValue(), Fiat.SMALLEST_UNIT_EXPONENT)) .findFirst() .orElse(usdBTCPrice); var bsqAmount = MathUtils.scaleDownByPowerOf10((double) item.getTradeVolume().getValue(), Altcoin.SMALLEST_UNIT_EXPONENT); var btcAmount = MathUtils.scaleDownByPowerOf10((double) item.getTradeAmount().getValue(), Altcoin.SMALLEST_UNIT_EXPONENT); usdBsqList.add(new Tuple2<>(usdBTCPrice * btcAmount, bsqAmount)); } long averagePrice; var usdTraded = usdBsqList.stream() .mapToDouble(item -> item.first) .sum(); var bsqTraded = usdBsqList.stream() .mapToDouble(item -> item.second) .sum(); var averageAsDouble = bsqTraded > 0 ? usdTraded / bsqTraded : 0d; var averageScaledUp = MathUtils.scaleUpByPowerOf10(averageAsDouble, Fiat.SMALLEST_UNIT_EXPONENT); averagePrice = bsqTraded > 0 ? MathUtils.roundDoubleToLong(averageScaledUp) : 0; return averagePrice; }
Example #11
Source File: MutableOfferViewModel.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void updateMarketPriceToManual() { final String currencyCode = dataModel.getTradeCurrencyCode().get(); MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode); if (marketPrice != null && marketPrice.isRecentExternalPriceAvailable()) { double marketPriceAsDouble = marketPrice.getPrice(); double amountAsDouble = ParsingUtils.parseNumberStringToDouble(amount.get()); double volumeAsDouble = ParsingUtils.parseNumberStringToDouble(volume.get()); double manualPriceAsDouble = dataModel.calculateMarketPriceManual(marketPriceAsDouble, volumeAsDouble, amountAsDouble); final boolean isCryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode); int precision = isCryptoCurrency ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT; price.set(FormattingUtils.formatRoundedDoubleWithPrecision(manualPriceAsDouble, precision)); setPriceToModel(); dataModel.calculateTotalToPay(); updateButtonDisableState(); applyMakerFee(); } else { marketPriceMargin.set(""); String id = "showNoPriceFeedAvailablePopup"; if (preferences.showAgain(id)) { new Popup().warning(Res.get("popup.warning.noPriceFeedAvailable")) .dontShowAgainId(id) .show(); } } }
Example #12
Source File: DisplayUtils.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private static String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) { if (volume != null) { Monetary monetary = volume.getMonetary(); if (monetary instanceof Fiat) return FormattingUtils.formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode); else return FormattingUtils.formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode); } else { return ""; } }
Example #13
Source File: TradesChartsViewModelTest.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("ConstantConditions") @Test public void testGetCandleData() { model.selectedTradeCurrencyProperty.setValue(new FiatCurrency("EUR")); long low = Fiat.parseFiat("EUR", "500").value; long open = Fiat.parseFiat("EUR", "520").value; long close = Fiat.parseFiat("EUR", "580").value; long high = Fiat.parseFiat("EUR", "600").value; long average = Fiat.parseFiat("EUR", "550").value; long median = Fiat.parseFiat("EUR", "550").value; long amount = Coin.parseCoin("4").value; long volume = Fiat.parseFiat("EUR", "2200").value; boolean isBullish = true; Set<TradeStatistics2> set = new HashSet<>(); final Date now = new Date(); set.add(new TradeStatistics2(offer, Price.parse("EUR", "520"), Coin.parseCoin("1"), new Date(now.getTime()), null, null)); set.add(new TradeStatistics2(offer, Price.parse("EUR", "500"), Coin.parseCoin("1"), new Date(now.getTime() + 100), null, null)); set.add(new TradeStatistics2(offer, Price.parse("EUR", "600"), Coin.parseCoin("1"), new Date(now.getTime() + 200), null, null)); set.add(new TradeStatistics2(offer, Price.parse("EUR", "580"), Coin.parseCoin("1"), new Date(now.getTime() + 300), null, null)); CandleData candleData = model.getCandleData(model.roundToTick(now, TradesChartsViewModel.TickUnit.DAY).getTime(), set); assertEquals(open, candleData.open); assertEquals(close, candleData.close); assertEquals(high, candleData.high); assertEquals(low, candleData.low); assertEquals(average, candleData.average); assertEquals(median, candleData.median); assertEquals(amount, candleData.accumulatedAmount); assertEquals(volume, candleData.accumulatedVolume); assertEquals(isBullish, candleData.isBullish); }
Example #14
Source File: OfferUtil.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private static Optional<Volume> getFeeInUserFiatCurrency(Coin makerFee, boolean isCurrencyForMakerFeeBtc, String userCurrencyCode, PriceFeedService priceFeedService, CoinFormatter bsqFormatter) { // We use the users currency derived from his selected country. // We don't use the preferredTradeCurrency from preferences as that can be also set to an altcoin. MarketPrice marketPrice = priceFeedService.getMarketPrice(userCurrencyCode); if (marketPrice != null && makerFee != null) { long marketPriceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(marketPrice.getPrice(), Fiat.SMALLEST_UNIT_EXPONENT)); Price userCurrencyPrice = Price.valueOf(userCurrencyCode, marketPriceAsLong); if (isCurrencyForMakerFeeBtc) { return Optional.of(userCurrencyPrice.getVolumeByAmount(makerFee)); } else { Optional<Price> optionalBsqPrice = priceFeedService.getBsqPrice(); if (optionalBsqPrice.isPresent()) { Price bsqPrice = optionalBsqPrice.get(); String inputValue = bsqFormatter.formatCoin(makerFee); Volume makerFeeAsVolume = Volume.parse(inputValue, "BSQ"); Coin requiredBtc = bsqPrice.getAmountByVolume(makerFeeAsVolume); return Optional.of(userCurrencyPrice.getVolumeByAmount(requiredBtc)); } else { return Optional.empty(); } } } else { return Optional.empty(); } }
Example #15
Source File: TradeStatistics2.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public Volume getTradeVolume() { if (getTradePrice().getMonetary() instanceof Altcoin) { return new Volume(new AltcoinExchangeRate((Altcoin) getTradePrice().getMonetary()).coinToAltcoin(getTradeAmount())); } else { Volume volume = new Volume(new ExchangeRate((Fiat) getTradePrice().getMonetary()).coinToFiat(getTradeAmount())); return OfferUtil.getRoundedFiatVolume(volume); } }
Example #16
Source File: Price.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
/** * Parse the Bitcoin {@code Price} given a {@code currencyCode} and {@code inputValue}. * * @param currencyCode The currency code to parse, e.g "USD" or "LTC". * @param input The input value to parse as a String, e.g "2.54" or "-0.0001". * @return The parsed Price. */ public static Price parse(String currencyCode, String input) { String cleaned = ParsingUtils.convertCharsForNumber(input); if (CurrencyUtil.isFiatCurrency(currencyCode)) return new Price(Fiat.parseFiat(currencyCode, cleaned)); else return new Price(Altcoin.parseAltcoin(currencyCode, cleaned)); }
Example #17
Source File: Price.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
/** * Parse the Bitcoin {@code Price} given a {@code currencyCode} and {@code inputValue}. * * @param currencyCode The currency code to parse, e.g "USD" or "LTC". * @param value The value to parse. * @return The parsed Price. */ public static Price valueOf(String currencyCode, long value) { if (CurrencyUtil.isFiatCurrency(currencyCode)) { return new Price(Fiat.valueOf(currencyCode, value)); } else { return new Price(Altcoin.valueOf(currencyCode, value)); } }
Example #18
Source File: Price.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public Volume getVolumeByAmount(Coin amount) { if (monetary instanceof Fiat) return new Volume(new ExchangeRate((Fiat) monetary).coinToFiat(amount)); else if (monetary instanceof Altcoin) return new Volume(new AltcoinExchangeRate((Altcoin) monetary).coinToAltcoin(amount)); else throw new IllegalStateException("Monetary must be either of type Fiat or Altcoin"); }
Example #19
Source File: Price.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public Coin getAmountByVolume(Volume volume) { Monetary monetary = volume.getMonetary(); if (monetary instanceof Fiat && this.monetary instanceof Fiat) return new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary); else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin) return new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary); else return Coin.ZERO; }
Example #20
Source File: Price.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public Price subtract(Price other) { if (monetary instanceof Altcoin) { return new Price(((Altcoin) monetary).subtract((Altcoin) other.monetary)); } else { return new Price(((Fiat) monetary).subtract((Fiat) other.monetary)); } }
Example #21
Source File: Volume.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static Volume parse(String input, String currencyCode) { String cleaned = ParsingUtils.convertCharsForNumber(input); if (CurrencyUtil.isFiatCurrency(currencyCode)) return new Volume(Fiat.parseFiat(currencyCode, cleaned)); else return new Volume(Altcoin.parseAltcoin(currencyCode, cleaned)); }
Example #22
Source File: FormattingUtils.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static String formatPrice(Price price, MonetaryFormat fiatPriceFormat, boolean appendCurrencyCode) { if (price != null) { Monetary monetary = price.getMonetary(); if (monetary instanceof Fiat) return formatFiat((Fiat) monetary, fiatPriceFormat, appendCurrencyCode); else return formatAltcoin((Altcoin) monetary, appendCurrencyCode); } else { return Res.get("shared.na"); } }
Example #23
Source File: Offer.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Nullable public Price getPrice() { String currencyCode = getCurrencyCode(); if (offerPayload.isUseMarketBasedPrice()) { checkNotNull(priceFeedService, "priceFeed must not be null"); MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode); if (marketPrice != null && marketPrice.isRecentExternalPriceAvailable()) { double factor; double marketPriceMargin = offerPayload.getMarketPriceMargin(); if (CurrencyUtil.isCryptoCurrency(currencyCode)) { factor = getDirection() == OfferPayload.Direction.SELL ? 1 - marketPriceMargin : 1 + marketPriceMargin; } else { factor = getDirection() == OfferPayload.Direction.BUY ? 1 - marketPriceMargin : 1 + marketPriceMargin; } double marketPriceAsDouble = marketPrice.getPrice(); double targetPriceAsDouble = marketPriceAsDouble * factor; try { int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT; double scaled = MathUtils.scaleUpByPowerOf10(targetPriceAsDouble, precision); final long roundedToLong = MathUtils.roundDoubleToLong(scaled); return Price.valueOf(currencyCode, roundedToLong); } catch (Exception e) { log.error("Exception at getPrice / parseToFiat: " + e.toString() + "\n" + "That case should never happen."); return null; } } else { log.trace("We don't have a market price. " + "That case could only happen if you don't have a price feed."); return null; } } else { return Price.valueOf(currencyCode, offerPayload.getPrice()); } }
Example #24
Source File: WalletTest.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@Test public void sendRequestExchangeRate() throws Exception { receiveATransaction(wallet, myAddress); SendRequest sendRequest = SendRequest.to(myAddress, Coin.COIN); sendRequest.exchangeRate = new ExchangeRate(Fiat.parseFiat("EUR", "500")); wallet.completeTx(sendRequest); assertEquals(sendRequest.exchangeRate, sendRequest.tx.getExchangeRate()); }
Example #25
Source File: Price.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
/** * Parse the Bitcoin {@code Price} given a {@code currencyCode} and {@code inputValue}. * * @param currencyCode The currency code to parse, e.g "USD" or "LTC". * @param value The value to parse. * @return The parsed Price. */ public static Price valueOf(String currencyCode, long value) { if (CurrencyUtil.isFiatCurrency(currencyCode)) { return new Price(Fiat.valueOf(currencyCode, value)); } else { return new Price(Altcoin.valueOf(currencyCode, value)); } }
Example #26
Source File: Offer.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
@Nullable public Price getPrice() { String currencyCode = getCurrencyCode(); if (offerPayload.isUseMarketBasedPrice()) { checkNotNull(priceFeedService, "priceFeed must not be null"); MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode); if (marketPrice != null && marketPrice.isRecentExternalPriceAvailable()) { double factor; double marketPriceMargin = offerPayload.getMarketPriceMargin(); if (CurrencyUtil.isCryptoCurrency(currencyCode)) { factor = getDirection() == OfferPayload.Direction.SELL ? 1 - marketPriceMargin : 1 + marketPriceMargin; } else { factor = getDirection() == OfferPayload.Direction.BUY ? 1 - marketPriceMargin : 1 + marketPriceMargin; } double marketPriceAsDouble = marketPrice.getPrice(); double targetPriceAsDouble = marketPriceAsDouble * factor; try { int precision = CurrencyUtil.isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT; double scaled = MathUtils.scaleUpByPowerOf10(targetPriceAsDouble, precision); final long roundedToLong = MathUtils.roundDoubleToLong(scaled); return Price.valueOf(currencyCode, roundedToLong); } catch (Exception e) { log.error("Exception at getPrice / parseToFiat: " + e.toString() + "\n" + "That case should never happen."); return null; } } else { log.debug("We don't have a market price.\n" + "That case could only happen if you don't have a price feed."); return null; } } else { return Price.valueOf(currencyCode, offerPayload.getPrice()); } }
Example #27
Source File: BSFormatter.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
public String formatPrice(Price price, MonetaryFormat fiatPriceFormat, boolean appendCurrencyCode) { if (price != null) { Monetary monetary = price.getMonetary(); if (monetary instanceof Fiat) return formatFiat((Fiat) monetary, fiatPriceFormat, appendCurrencyCode); else return formatAltcoin((Altcoin) monetary, appendCurrencyCode); } else { return Res.get("shared.na"); } }
Example #28
Source File: BSFormatter.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
public String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) { if (volume != null) { Monetary monetary = volume.getMonetary(); if (monetary instanceof Fiat) return formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode); else return formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode); } else { return ""; } }
Example #29
Source File: BSFormatter.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
/** * Converts to a fiat with max. 2 decimal places. Last place gets rounded. * 0.234 -> 0.23 * 0.235 -> 0.24 * * @param input * @return */ public Fiat parseToFiatWithPrecision(String input, String currencyCode) { if (input != null && input.length() > 0) { try { return parseToFiat(new BigDecimal(cleanDoubleInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(), currencyCode); } catch (Throwable t) { log.warn("Exception at parseToFiatWithPrecision: " + t.toString()); return Fiat.valueOf(currencyCode, 0); } } return Fiat.valueOf(currencyCode, 0); }
Example #30
Source File: BSFormatter.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
protected Fiat parseToFiat(String input, String currencyCode) { if (input != null && input.length() > 0) { try { return Fiat.parseFiat(currencyCode, cleanDoubleInput(input)); } catch (Exception e) { log.warn("Exception at parseToFiat: " + e.toString()); return Fiat.valueOf(currencyCode, 0); } } else { return Fiat.valueOf(currencyCode, 0); } }