01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (license2)
04: * Initial Developer: H2 Group
05: */
06: package org.h2.test.unit;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.constant.ErrorCode;
11: import org.h2.test.TestBase;
12: import org.h2.util.DateTimeUtils;
13: import org.h2.value.Value;
14:
15: /**
16: * Tests the data parsing. The problem is that some dates are not allowed
17: * because of the summer time change. Most countries change at 2 o'clock in the
18: * morning to 3 o'clock, but some (for example Chile) change at midnight.
19: * Non-lenient parsing would not work in this case.
20: */
21: public class TestDate extends TestBase {
22:
23: public void test() throws Exception {
24: for (int year = 1970; year < 2070; year++) {
25: for (int month = 1; month <= 12; month++) {
26: for (int day = 1; day < 29; day++) {
27: for (int hour = 0; hour < 24; hour++) {
28: test(year, month, day, hour);
29: }
30: }
31: }
32: }
33: }
34:
35: private void test(int year, int month, int day, int hour)
36: throws SQLException {
37: DateTimeUtils.parseDateTime(year + "-" + month + "-" + day
38: + " " + hour + ":00:00", Value.TIMESTAMP,
39: ErrorCode.TIMESTAMP_CONSTANT_2);
40: }
41:
42: }
|