1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
279 @Test(dataProvider="offsets")
280 public void test_parse_midStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
281 ParsePosition pos = new ParsePosition(5);
282 TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse + ":OTHER", pos);
283 assertEquals(pos.getIndex(), parse.length() + 5);
284 assertParsed(parsed, expected);
285 }
286
287 @Test(dataProvider="offsets")
288 public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
289 ParsePosition pos = new ParsePosition(5);
290 TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos);
291 assertEquals(pos.getIndex(), parse.length() + 5);
292 assertParsed(parsed, expected);
293 }
294
295 //-----------------------------------------------------------------------
296 @DataProvider(name="bigOffsets")
297 Object[][] provider_bigOffsets() {
298 return new Object[][] {
299 {"+HH", "+59", 59 * 3600},
300 {"+HH", "-19", -(19 * 3600)},
301
302 {"+HHMM", "+1801", 18 * 3600 + 1 * 60},
303 {"+HHMM", "-1801", -(18 * 3600 + 1 * 60)},
304
305 {"+HH:MM", "+18:01", 18 * 3600 + 1 * 60},
306 {"+HH:MM", "-18:01", -(18 * 3600 + 1 * 60)},
307
308 {"+HHMMss", "+180103", 18 * 3600 + 1 * 60 + 3},
309 {"+HHMMss", "-180103", -(18 * 3600 + 1 * 60 + 3)},
310
311 {"+HH:MM:ss", "+18:01:03", 18 * 3600 + 1 * 60 + 3},
312 {"+HH:MM:ss", "-18:01:03", -(18 * 3600 + 1 * 60 + 3)},
313
314 {"+HHMMSS", "+180103", 18 * 3600 + 1 * 60 + 3},
315 {"+HHMMSS", "-180103", -(18 * 3600 + 1 * 60 + 3)},
316
317 {"+HH:MM:SS", "+18:01:03", 18 * 3600 + 1 * 60 + 3},
318 {"+HH:MM:SS", "-18:01:03", -(18 * 3600 + 1 * 60 + 3)},
319 };
|
1 /*
2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
279 @Test(dataProvider="offsets")
280 public void test_parse_midStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
281 ParsePosition pos = new ParsePosition(5);
282 TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse + ":OTHER", pos);
283 assertEquals(pos.getIndex(), parse.length() + 5);
284 assertParsed(parsed, expected);
285 }
286
287 @Test(dataProvider="offsets")
288 public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
289 ParsePosition pos = new ParsePosition(5);
290 TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos);
291 assertEquals(pos.getIndex(), parse.length() + 5);
292 assertParsed(parsed, expected);
293 }
294
295 //-----------------------------------------------------------------------
296 @DataProvider(name="bigOffsets")
297 Object[][] provider_bigOffsets() {
298 return new Object[][] {
299 {"+HH", "+19", 19 * 3600},
300 {"+HH", "-19", -(19 * 3600)},
301
302 {"+HHMM", "+1801", 18 * 3600 + 1 * 60},
303 {"+HHMM", "-1801", -(18 * 3600 + 1 * 60)},
304
305 {"+HH:MM", "+18:01", 18 * 3600 + 1 * 60},
306 {"+HH:MM", "-18:01", -(18 * 3600 + 1 * 60)},
307
308 {"+HHMMss", "+180103", 18 * 3600 + 1 * 60 + 3},
309 {"+HHMMss", "-180103", -(18 * 3600 + 1 * 60 + 3)},
310
311 {"+HH:MM:ss", "+18:01:03", 18 * 3600 + 1 * 60 + 3},
312 {"+HH:MM:ss", "-18:01:03", -(18 * 3600 + 1 * 60 + 3)},
313
314 {"+HHMMSS", "+180103", 18 * 3600 + 1 * 60 + 3},
315 {"+HHMMSS", "-180103", -(18 * 3600 + 1 * 60 + 3)},
316
317 {"+HH:MM:SS", "+18:01:03", 18 * 3600 + 1 * 60 + 3},
318 {"+HH:MM:SS", "-18:01:03", -(18 * 3600 + 1 * 60 + 3)},
319 };
|