From: James Ahlborn Date: Fri, 5 Oct 2018 19:10:29 +0000 (+0000) Subject: handle am/pm suffix dependent on date/time config X-Git-Tag: jackcess-2.2.1~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=535e01e48552081565dc76b98148fa0a2a67c52d;p=jackcess.git handle am/pm suffix dependent on date/time config git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1206 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java index 5b2864a..3dfa361 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java @@ -53,9 +53,6 @@ class ExpressionTokenizer private static final char DATE_LIT_QUOTE_CHAR = '#'; private static final char EQUALS_CHAR = '='; - private static final int AMPM_SUFFIX_LEN = 3; - private static final String AM_SUFFIX = " am"; - private static final String PM_SUFFIX = " pm"; // access times are based on this date (not the UTC base) private static final String BASE_DATE = "12/30/1899"; private static final String BASE_DATE_FMT = "M/d/yyyy"; @@ -323,12 +320,10 @@ class ExpressionTokenizer boolean hasAmPm = false; if(hasTime) { - int strLen = dateStr.length(); - hasAmPm = ((strLen >= AMPM_SUFFIX_LEN) && - (dateStr.regionMatches(true, strLen - AMPM_SUFFIX_LEN, - AM_SUFFIX, 0, AMPM_SUFFIX_LEN) || - dateStr.regionMatches(true, strLen - AMPM_SUFFIX_LEN, - PM_SUFFIX, 0, AMPM_SUFFIX_LEN))); + String[] amPmStrs = cfg.getDateFormatSymbols().getAmPmStrings(); + String amStr = " " + amPmStrs[0]; + String pmStr = " " + amPmStrs[1]; + hasAmPm = (hasSuffix(dateStr, amStr) || hasSuffix(dateStr, pmStr)); } if(hasDate) { @@ -344,6 +339,14 @@ class ExpressionTokenizer return null; } + private static boolean hasSuffix(String str, String suffStr) { + int strLen = str.length(); + int suffStrLen = suffStr.length(); + return ((strLen >= suffStrLen) && + str.regionMatches(true, strLen - suffStrLen, + suffStr, 0, suffStrLen)); + } + static DateFormat createParseDateTimeFormat(TemporalConfig.Type type, LocaleContext ctx) {