trying to make the testcase timezone independent

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2004-10-11 20:32:44 +00:00
parent b6d184b28f
commit 257adde8c7
1 changed files with 12 additions and 5 deletions

View File

@ -52,11 +52,18 @@ public class TestDateTools extends TestCase {
}
public void testStringtotime() throws ParseException {
long time = DateTools.stringToTime("197001010100");
assertEquals(0, time);
time = DateTools.stringToTime("197001010102");
assertEquals(120000, time);
public void testStringtoTime() throws ParseException {
long time = DateTools.stringToTime("197001010000");
Calendar cal = Calendar.getInstance();
cal.set(1970, 0, 1, // year=1970, month=january, day=1
0, 0, 0); // hour, minute, second
cal.set(Calendar.MILLISECOND, 0);
assertEquals(cal.getTime().getTime(), time);
cal.set(1980, 1, 2, // year=1980, month=february, day=2
11, 5, 0); // hour, minute, second
cal.set(Calendar.MILLISECOND, 0);
time = DateTools.stringToTime("198002021105");
assertEquals(cal.getTime().getTime(), time);
}
public void testDateAndTimetoString() throws ParseException {