/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4919632
* @summary Unit test for ISO8601 time zone format support
*/
public class ISO8601ZoneTest {
// time zone name, expected output at TIMESTAMP
{ "America/Los_Angeles", "2010-09-06T00:27:19.020-07", },
{ "America/Los_Angeles", "2010-09-06T00:27:19.020-0700", },
{ "America/Los_Angeles", "2010-09-06T00:27:19.020-07:00", },
{ "GMT-07:00", "2010-09-06T00:27:19.020-07", },
{ "GMT-07:00", "2010-09-06T00:27:19.020-0700", },
{ "GMT-07:00", "2010-09-06T00:27:19.020-07:00", },
{ "UTC", "2010-09-06T07:27:19.020Z", },
{ "UTC", "2010-09-06T07:27:19.020Z", },
{ "UTC", "2010-09-06T07:27:19.020Z", },
};
"UTC", "GMT+05:30", "GMT-01:23",
};
"yyyy-MM-dd'T'HH:mm:ss.SSSX",
"yyyy-MM-dd'T'HH:mm:ss.SSSXX",
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
};
// badData[][0] - format
// badData[][1] - (bad) text to be parsed
// badData[][2] - subtext at the end of which a parse error is detected
{ "X", "1", "1" },
{ "X", "+1", "+1" },
{ "X", "-2", "-2" },
{ "X", "-24", "-2" },
{ "X", "+24", "+2" },
{ "XX", "9", "9" },
{ "XX", "23", "2" },
{ "XX", "234", "2" },
{ "XX", "3456", "3" },
{ "XX", "23456", "2" },
{ "XX", "+1", "+1" },
{ "XX", "-12", "-12" },
{ "XX", "+123", "+123" },
{ "XX", "-12:34", "-12" },
{ "XX", "+12:34", "+12" },
{ "XX", "-2423", "-2" },
{ "XX", "+2423", "+2" },
{ "XX", "-1260", "-126" },
{ "XX", "+1260", "+126" },
{ "XXX", "9", "9" },
{ "XXX", "23", "2" },
{ "XXX", "234", "2" },
{ "XXX", "3456", "3" },
{ "XXX", "23456", "2" },
{ "XXX", "2:34", "2" },
{ "XXX", "12:4", "1" },
{ "XXX", "12:34", "1" },
{ "XXX", "-1", "-1" },
{ "XXX", "+1", "+1" },
{ "XXX", "-12", "-12" },
{ "XXX", "+12", "+12" },
{ "XXX", "-123", "-12" },
{ "XXX", "+123", "+12" },
{ "XXX", "-1234", "-12" },
{ "XXX", "+1234", "+12" },
{ "XXX", "+24:23", "+2" },
{ "XXX", "+12:60", "+12:6" },
{ "XXX", "+1:23", "+1" },
{ "XXX", "+12:3", "+12:3" },
};
"XXXX", "XXXXX", "XXXXXX",
};
try {
formatData[i][1]);
}
}
}
}
}
} finally {
}
}
throw new RuntimeException("formatTest: got " + s
+ ", expected " + expected);
}
throw new RuntimeException("formatTest: parse(" + s
+ "), got " + d.getTime()
}
throw new RuntimeException("formatTest: parse(" + s
+ "), got " + d.getTime()
}
throw new RuntimeException("formatTest: wrong resulting parse position: "
}
}
if (diffsInMillis != 0) {
if (diffsInMillis != fractionalHour) {
+ ", diff="+diffsInMillis
+ ", fraction=" + fractionalHour);
}
}
}
try {
+ ", text=" + text);
} catch (ParseException e) {
// OK
}
+ ", expected=" + expectedErrorIndex
}
}
try {
} catch (IllegalArgumentException e) {
// OK
}
try {
} catch (IllegalArgumentException e) {
// OK
}
}
}