mirror of https://github.com/apache/lucene.git
- Modified to use localized date strings.
Submitted by: Christoph Kiehl Reviewed by: Otis git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7248b18b1d
commit
241b2d6a85
|
@ -281,11 +281,20 @@ public class TestQueryParser extends TestCase {
|
|||
return DateField.dateToString(df.parse(s));
|
||||
}
|
||||
|
||||
public String getLocalizedDate(int year, int month, int day) {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(year, month, day);
|
||||
return df.format(calendar.getTime());
|
||||
}
|
||||
|
||||
public void testDateRange() throws Exception {
|
||||
assertQueryEquals("[ 1/1/02 TO 1/4/02]", null,
|
||||
"[" + getDate("1/1/02") + "-" + getDate("1/4/02") + "]");
|
||||
assertQueryEquals("{ 1/1/02 1/4/02 }", null,
|
||||
"{" + getDate("1/1/02") + "-" + getDate("1/4/02") + "}");
|
||||
String startDate = getLocalizedDate(2002, 1, 1);
|
||||
String endDate = getLocalizedDate(2002, 1, 4);
|
||||
assertQueryEquals("[ " + startDate + " TO " + endDate + "]", null,
|
||||
"[" + getDate(startDate) + "-" + getDate(endDate) + "]");
|
||||
assertQueryEquals("{ " + startDate + " " + endDate + " }", null,
|
||||
"{" + getDate(startDate) + "-" + getDate(endDate) + "}");
|
||||
}
|
||||
|
||||
public void testEscaped() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue