From 43893dc20e2552b711e85b453fa939efbc8bbbc2 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 26 Nov 2019 23:57:13 +0200 Subject: [PATCH] LedgerTransaction.asParsedTransaction: handle null date defaulting to today --- .../net/ktnx/mobileledger/model/LedgerTransaction.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); -- 2.39.5