mirror of https://github.com/apache/lucene.git
LUCENE-1846: Fix more Locale problems
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@807117 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
481245def6
commit
5dd1810b0c
|
@ -195,6 +195,12 @@ Changes in runtime behavior
|
|||
basis. There is currently no way provided to rebase the docids in the Scorer to
|
||||
the top level IndexReader. (Mark Miller, Mike McCandless)
|
||||
|
||||
14. LUCENE-1846: DateTools now uses the US locale to format the numbers in its
|
||||
date/time strings instead of the default locale. For most locales there will
|
||||
be no change in the index format, as DateFormatSymbols is using ASCII digits.
|
||||
The usage of the US locale is important to guarantee correct ordering of
|
||||
generated terms. (Uwe Schindler)
|
||||
|
||||
API Changes
|
||||
|
||||
1. LUCENE-1419: Add expert API to set custom indexing chain. This API is
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.lucene.analysis.sinks;
|
|||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class DateRecognizerSinkTokenizerTest extends TestCase {
|
|||
}
|
||||
|
||||
public void test() throws IOException {
|
||||
DateRecognizerSinkFilter sinkFilter = new DateRecognizerSinkFilter(new SimpleDateFormat("MM/dd/yyyy"));
|
||||
DateRecognizerSinkFilter sinkFilter = new DateRecognizerSinkFilter(new SimpleDateFormat("MM/dd/yyyy", Locale.US));
|
||||
String test = "The quick red fox jumped over the lazy brown dogs on 7/11/2006 The dogs finally reacted on 7/12/2006";
|
||||
TeeSinkTokenFilter tee = new TeeSinkTokenFilter(new WhitespaceTokenizer(new StringReader(test)));
|
||||
SinkTokenStream sink = tee.newSinkTokenStream(sinkFilter);
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Locale;
|
||||
import org.apache.lucene.search.NumericRangeQuery; // for javadocs
|
||||
import org.apache.lucene.util.NumericUtils; // for javadocs
|
||||
|
||||
|
@ -52,13 +53,13 @@ public class DateTools {
|
|||
|
||||
private final static TimeZone GMT = TimeZone.getTimeZone("GMT");
|
||||
|
||||
private static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy");
|
||||
private static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyyMM");
|
||||
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
||||
private static final SimpleDateFormat HOUR_FORMAT = new SimpleDateFormat("yyyyMMddHH");
|
||||
private static final SimpleDateFormat MINUTE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
private static final SimpleDateFormat SECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
private static final SimpleDateFormat MILLISECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
private static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy", Locale.US);
|
||||
private static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyyMM", Locale.US);
|
||||
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd", Locale.US);
|
||||
private static final SimpleDateFormat HOUR_FORMAT = new SimpleDateFormat("yyyyMMddHH", Locale.US);
|
||||
private static final SimpleDateFormat MINUTE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.US);
|
||||
private static final SimpleDateFormat SECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
|
||||
private static final SimpleDateFormat MILLISECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.US);
|
||||
static {
|
||||
// times need to be normalized so the value doesn't depend on the
|
||||
// location the index is created/used:
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
|
@ -172,7 +173,7 @@ public class TestDateTools extends LuceneTestCase {
|
|||
}
|
||||
|
||||
private String isoFormat(Date date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.US);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue