Manfred Karrer 2019-01-29 21:53:32 +01:00
parent 1e6777bb09
commit 5316c871c5
No known key found for this signature in database
GPG key ID: 401250966A6B2C46

View file

@ -20,6 +20,7 @@ package bisq.core.util;
import bisq.core.app.BisqEnvironment;
import bisq.core.dao.exceptions.ValidationException;
import bisq.core.dao.governance.param.Param;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
import bisq.core.provider.price.MarketPrice;
import bisq.core.util.validation.BtcAddressValidator;
@ -36,6 +37,9 @@ import org.bitcoinj.utils.MonetaryFormat;
import javax.inject.Inject;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
import lombok.extern.slf4j.Slf4j;
@ -44,14 +48,17 @@ public class BsqFormatter extends BSFormatter {
@SuppressWarnings("PointlessBooleanExpression")
private static final boolean useBsqAddressFormat = true || !DevEnv.isDevMode();
private final String prefix = "B";
private final DecimalFormat amountFormat = new DecimalFormat("###,###,###.##");
private final DecimalFormat marketCapFormat = new DecimalFormat("###,###,###");
private DecimalFormat amountFormat;
private DecimalFormat marketCapFormat;
private final MonetaryFormat btcCoinFormat;
@Inject
public BsqFormatter() {
super();
GlobalSettings.localeProperty().addListener((observable, oldValue, newValue) -> setFormatter(newValue));
setFormatter(GlobalSettings.getLocale());
btcCoinFormat = super.coinFormat;
final String baseCurrencyCode = BisqEnvironment.getBaseCurrencyNetwork().getCurrencyCode();
@ -73,6 +80,16 @@ public class BsqFormatter extends BSFormatter {
amountFormat.setMinimumFractionDigits(2);
}
private void setFormatter(Locale locale) {
amountFormat = (DecimalFormat) NumberFormat.getNumberInstance(locale);
amountFormat.setMinimumFractionDigits(2);
amountFormat.setMaximumFractionDigits(2);
marketCapFormat = (DecimalFormat) NumberFormat.getNumberInstance(locale);
marketCapFormat = new DecimalFormat();
marketCapFormat.setMaximumFractionDigits(0);
}
/**
* Returns the base-58 encoded String representation of this
* object, including version and checksum bytes.