From: Damyan Ivanov Date: Tue, 26 Nov 2019 21:57:13 +0000 (+0200) Subject: LedgerTransaction.asParsedTransaction: handle null date defaulting to today X-Git-Tag: v0.11.0~18 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=43893dc20e2552b711e85b453fa939efbc8bbbc2;p=mobile-ledger.git LedgerTransaction.asParsedTransaction: handle null date defaulting to today --- diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java index fd900efa..252b32f4 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java @@ -31,6 +31,7 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; +import java.util.GregorianCalendar; public class LedgerTransaction { private static final String DIGEST_TYPE = "SHA-256"; @@ -201,7 +202,11 @@ public class LedgerTransaction { } result.setTpostings(postings); - result.setTdate(Globals.formatIsoDate(date)); + Date transactionDate = date; + if (transactionDate == null) { + transactionDate = new GregorianCalendar().getTime(); + } + result.setTdate(Globals.formatIsoDate(transactionDate)); result.setTdate2(null); result.setTindex(1); result.setTdescription(description);