X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Futils%2FGlobals.java;h=8f010cbee7435c12411ed787600496b8baef625c;hp=8a2c8366659e76253082e0915626a48c02b539bd;hb=42498bba93a54e96070e976da2415c10b713e38b;hpb=0974c053bfa714958b1ce911865907085232a6d9 diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java index 8a2c8366..8f010cbe 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java @@ -19,7 +19,6 @@ package net.ktnx.mobileledger.utils; import android.app.Activity; import android.content.Context; -import android.support.annotation.ColorInt; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -32,16 +31,15 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public final class Globals { - @ColorInt - public static int tableRowLightBG; - @ColorInt - public static int tableRowDarkBG; - @ColorInt - public static int primaryDark, defaultTextColor; + private static final ThreadLocal dateFormatter = + new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy/MM/dd", Locale.US); + } + }; public static String[] monthNames; public static String developerEmail = "dam+mole-crash@ktnx.net"; - private static SimpleDateFormat ledgerDateFormatter = - new SimpleDateFormat("yyyy/MM/dd", Locale.US); private static Pattern reLedgerDate = Pattern.compile("^(?:(\\d+)/)??(?:(\\d\\d?)/)?(\\d\\d?)$"); public static void hideSoftKeyboard(Activity act) { @@ -55,7 +53,9 @@ public final class Globals { } public static Date parseLedgerDate(String dateString) throws ParseException { Matcher m = reLedgerDate.matcher(dateString); - if (!m.matches()) throw new ParseException(dateString, 0); + if (!m.matches()) throw new ParseException( + String.format("'%s' does not match expected pattern '%s'", dateString, + reLedgerDate.toString()), 0); String year = m.group(1); String month = m.group(2); @@ -73,10 +73,9 @@ public final class Globals { } else toParse = dateString; -// Log.d("globals", String.format("Parsing date '%s'", toParse)); - return ledgerDateFormatter.parse(toParse); + return dateFormatter.get().parse(toParse); } public static String formatLedgerDate(Date date) { - return ledgerDateFormatter.format(date); + return dateFormatter.get().format(date); } } \ No newline at end of file