From: Damyan Ivanov Date: Sat, 15 Dec 2018 19:36:27 +0000 (+0000) Subject: helper method for getting transaction item (currency + amount) as string X-Git-Tag: v0.3~225 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=867ad7e441e63d3b7974f67dca8d11797e95a245;p=mobile-ledger.git helper method for getting transaction item (currency + amount) as string --- diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java index de430580..10842584 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java @@ -17,6 +17,8 @@ package net.ktnx.mobileledger.model; +import android.support.annotation.NonNull; + public class LedgerTransactionItem { private String accountName; private float amount; @@ -71,4 +73,17 @@ public class LedgerTransactionItem { public String getCurrency() { return currency; } + @NonNull + public String toString() { + if (!amountSet) return ""; + + StringBuilder sb = new StringBuilder(); + if (currency != null) { + sb.append(currency); + sb.append(' '); + } + sb.append(String.format("%,1.2f", amount)); + + return sb.toString(); + } }