price to 4 decimal digits

This commit is contained in:
Radek Davidek 2021-10-02 11:02:35 +02:00
parent 2934baee9d
commit e0b4da831c

View File

@ -78,16 +78,16 @@ public class MiningBean {
if (pos>=0) { if (pos>=0) {
JSONObject quote = (JSONObject) o.get("quote"); JSONObject quote = (JSONObject) o.get("quote");
JSONObject usd = (JSONObject) quote.get(currency.toUpperCase()); JSONObject usd = (JSONObject) quote.get(currency.toUpperCase());
double res = usd.getDouble("price"); double price = usd.getDouble("price");
double change = usd.getDouble("percent_change_24h"); double change = usd.getDouble("percent_change_24h");
lastPrices[pos] = res; lastPrices[pos] = price;
if (res > 0d) if (price > 0d)
resultStr = curSym + res + " ("+String.format("%.2f",(change))+"%)"; resultStr = curSym + String.format("%.4f",(price)) + " ("+String.format("%.2f",(change))+"%)";
else else
resultStr = "Unknown"; resultStr = "Unknown";
KeyValue wi = new KeyValue(); KeyValue wi = new KeyValue();
wi.setKey(symbol.concat("/").concat(currency.toUpperCase()).concat(" (CoinMarketCap)")); wi.setKey(symbol.concat("/").concat(currency.toUpperCase()));
wi.setValue(resultStr); wi.setValue(resultStr);
if (change>0) if (change>0)
wi.setColor("GREEN"); wi.setColor("GREEN");