]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/utils/Globals.java
replace dates in transaction list items with delimiters between items in different...
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / utils / Globals.java
index e32a4321247261207e8286ae20ae309b49e55ee5..30dec945a994b076385157d3ad22c8d3efc6a28d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
  * This file is part of Mobile-Ledger.
  * Mobile-Ledger is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -23,13 +23,19 @@ import android.support.annotation.ColorInt;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
 public final class Globals {
     @ColorInt
-    public static int table_row_even_bg;
+    public static int tableRowEvenBG;
     @ColorInt
-    public static int table_row_odd_bg;
+    public static int tableRowOddBG;
     @ColorInt
     public static int primaryDark, defaultTextColor;
+    public static String[] monthNames;
     public static void hideSoftKeyboard(Activity act) {
         // hide the keyboard
         View v = act.getCurrentFocus();
@@ -39,5 +45,16 @@ public final class Globals {
             imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         }
     }
-
+    private static SimpleDateFormat ledgerDateFormatter = new SimpleDateFormat("y/M/d", Locale.US);
+    public static Date parseLedgerDate(String dateString) {
+        try {
+            return ledgerDateFormatter.parse(dateString);
+        }
+        catch (ParseException e) {
+            throw new RuntimeException(String.format("Error parsing date '%s'", dateString), e);
+        }
+    }
+    public static String formatLedgerDate(Date date) {
+        return ledgerDateFormatter.format(date);
+    }
 }
\ No newline at end of file