NT model/setDate: replace empty dates with null
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 22:04:19 +0000 (00:04 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 26 Nov 2019 22:04:19 +0000 (00:04 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java

index a2f356c..39b9ac8 100644 (file)
@@ -378,6 +378,13 @@ public class NewTransactionModel extends ViewModel {
             this.date.setValue(date);
         }
         public void setDate(String text) {
+            if ((text == null) || text.trim()
+                                      .isEmpty())
+            {
+                setDate((Date) null);
+                return;
+            }
+
             int year, month, day;
             final Calendar c = GregorianCalendar.getInstance();
             Matcher m = reYMD.matcher(text);