From: Damyan Ivanov Date: Thu, 7 Mar 2019 03:37:12 +0000 (+0200) Subject: parser method for ISO date format (yyyy-mm-dd) X-Git-Tag: v0.8~38 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=8d38ad0a72f593bb131785bad2b8e54fbdc894fb;p=mobile-ledger.git parser method for ISO date format (yyyy-mm-dd) --- 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 8f010cbe..719d6e20 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java @@ -38,6 +38,13 @@ public final class Globals { return new SimpleDateFormat("yyyy/MM/dd", Locale.US); } }; + private static final ThreadLocal isoDateFormatter = + 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 Pattern reLedgerDate = @@ -75,6 +82,9 @@ public final class Globals { return dateFormatter.get().parse(toParse); } + public static Date parseIsoDate(String dateString) throws ParseException { + return isoDateFormatter.get().parse(dateString); + } public static String formatLedgerDate(Date date) { return dateFormatter.get().format(date); }