From 8d38ad0a72f593bb131785bad2b8e54fbdc894fb Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 7 Mar 2019 05:37:12 +0200 Subject: [PATCH] parser method for ISO date format (yyyy-mm-dd) --- .../main/java/net/ktnx/mobileledger/utils/Globals.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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); } -- 2.39.5