From 481cf76fe38b29b5eff2a73dcf74bb869459d9b9 Mon Sep 17 00:00:00 2001 From: Mats Byrkjeland Date: Wed, 17 Jun 2020 15:20:29 +0200 Subject: [PATCH] Fix return of wrong pattern piece MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The getPatternIncluding method would return quoted pieces if the check contents of the quoted part included the format letter. For instance for Danish (da_DK), the pattern is "EEE 'den' d. MMM" If we are calling `getPatternIncluding("d", "da_DK")`, the method would return `"den'"ยด, but we would like to return `"d."`. This commit ignores pieces with apostrophe ("'") in them. --- .../main/java/com/henninghall/date_picker/LocaleUtils.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java b/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java index 1585b6b..596ce91 100644 --- a/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java +++ b/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java @@ -17,7 +17,7 @@ public class LocaleUtils { */ public static String getPatternIncluding(String format, Locale locale) { for (String piece: getFullPatternPieces(locale)){ - if(piece.contains(format)) { + if(piece.contains(format) && !piece.contains("'")) { return piece; } } @@ -50,5 +50,3 @@ public class LocaleUtils { } } - -