- 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:
Otis Gospodnetic 2003-02-15 20:16:07 +00:00
parent 7248b18b1d
commit 241b2d6a85
1 changed files with 13 additions and 4 deletions

View File

@ -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 {