You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2009/08/24 10:31:34 UTC
svn commit: r807117 - in /lucene/java/trunk: ./
contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/
src/java/org/apache/lucene/document/ src/test/org/apache/lucene/document/
Author: uschindler
Date: Mon Aug 24 08:31:34 2009
New Revision: 807117
URL: http://svn.apache.org/viewvc?rev=807117&view=rev
Log:
LUCENE-1846: Fix more Locale problems
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/DateRecognizerSinkTokenizerTest.java
lucene/java/trunk/src/java/org/apache/lucene/document/DateTools.java
lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=807117&r1=807116&r2=807117&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Mon Aug 24 08:31:34 2009
@@ -195,6 +195,12 @@
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
Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/DateRecognizerSinkTokenizerTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/DateRecognizerSinkTokenizerTest.java?rev=807117&r1=807116&r2=807117&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/DateRecognizerSinkTokenizerTest.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/sinks/DateRecognizerSinkTokenizerTest.java Mon Aug 24 08:31:34 2009
@@ -19,6 +19,7 @@
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 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);
Modified: lucene/java/trunk/src/java/org/apache/lucene/document/DateTools.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/document/DateTools.java?rev=807117&r1=807116&r2=807117&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/DateTools.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/DateTools.java Mon Aug 24 08:31:34 2009
@@ -22,6 +22,7 @@
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 @@
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:
Modified: lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java?rev=807117&r1=807116&r2=807117&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java Mon Aug 24 08:31:34 2009
@@ -5,6 +5,7 @@
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 @@
}
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);
}