aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java21
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)
{