]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/LedgerAmount.java
6afea7d0928c8805e7dde43e6869345c8a513b1c
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / LedgerAmount.java
1 package net.ktnx.mobileledger;
2
3 import android.annotation.SuppressLint;
4 import android.support.annotation.NonNull;
5
6 class LedgerAmount {
7     private String currency;
8     private float amount;
9
10     public
11     LedgerAmount(float amount, @NonNull String currency) {
12         this.currency = currency;
13         this.amount = amount;
14     }
15
16     public
17     LedgerAmount(float amount) {
18         this.amount = amount;
19         this.currency = null;
20     }
21
22     @SuppressLint("DefaultLocale")
23     @NonNull
24     public String toString() {
25         if (currency == null) return String.format("%,1.2f", amount);
26         else return String.format("%s %,1.2f", currency, amount);
27     }
28 }