diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-10-05 19:10:29 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-10-05 19:10:29 +0000 |
commit | 535e01e48552081565dc76b98148fa0a2a67c52d (patch) | |
tree | 418651c26f2191f205c35d93d8dd8aba0302f4f5 | |
parent | 762312dd4904a77283b2fa849e0c5baca6c68d5a (diff) | |
download | jackcess-535e01e48552081565dc76b98148fa0a2a67c52d.tar.gz jackcess-535e01e48552081565dc76b98148fa0a2a67c52d.zip |
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
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java | 21 |
1 files changed, 12 insertions, 9 deletions
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) { |