• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
23 
24 /*
25  * This file is available under and governed by the GNU General Public
26  * License version 2 only, as published by the Free Software Foundation.
27  * However, the following notice accompanied the original version of this
28  * file:
29  *
30  * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
31  *
32  * All rights reserved.
33  *
34  * Redistribution and use in source and binary forms, with or without
35  * modification, are permitted provided that the following conditions are met:
36  *
37  *  * Redistributions of source code must retain the above copyright notice,
38  *    this list of conditions and the following disclaimer.
39  *
40  *  * Redistributions in binary form must reproduce the above copyright notice,
41  *    this list of conditions and the following disclaimer in the documentation
42  *    and/or other materials provided with the distribution.
43  *
44  *  * Neither the name of JSR-310 nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
52  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
53  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
56  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
57  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59  */
60 package tck.java.time.format;
61 
62 import static org.testng.Assert.assertEquals;
63 
64 import java.time.LocalDateTime;
65 import java.time.OffsetDateTime;
66 import java.time.ZoneId;
67 import java.time.ZoneOffset;
68 import java.time.ZonedDateTime;
69 import java.time.format.DateTimeFormatter;
70 import java.time.format.DateTimeFormatterBuilder;
71 import java.time.format.TextStyle;
72 
73 import org.testng.annotations.BeforeMethod;
74 import org.testng.annotations.DataProvider;
75 import org.testng.annotations.Test;
76 
77 /**
78  * Test DateTimeFormatterBuilder.appendOffset().
79  */
80 @Test
81 public class TCKOffsetPrinterParser {
82 
83     private static final ZoneOffset OFFSET_UTC = ZoneOffset.UTC;
84     private static final ZoneOffset OFFSET_P0100 = ZoneOffset.ofHours(1);
85     private static final ZoneOffset OFFSET_P0123 = ZoneOffset.ofHoursMinutes(1, 23);
86     private static final ZoneOffset OFFSET_P0023 = ZoneOffset.ofHoursMinutes(0, 23);
87     private static final ZoneOffset OFFSET_P012345 = ZoneOffset.ofHoursMinutesSeconds(1, 23, 45);
88     private static final ZoneOffset OFFSET_P000045 = ZoneOffset.ofHoursMinutesSeconds(0, 0, 45);
89     private static final ZoneOffset OFFSET_M0100 = ZoneOffset.ofHours(-1);
90     private static final ZoneOffset OFFSET_M0123 = ZoneOffset.ofHoursMinutes(-1, -23);
91     private static final ZoneOffset OFFSET_M0023 = ZoneOffset.ofHoursMinutes(0, -23);
92     private static final ZoneOffset OFFSET_M012345 = ZoneOffset.ofHoursMinutesSeconds(-1, -23, -45);
93     private static final ZoneOffset OFFSET_M000045 = ZoneOffset.ofHoursMinutesSeconds(0, 0, -45);
94     private static final LocalDateTime DT_2012_06_30_12_30_40 = LocalDateTime.of(2012, 6, 30, 12, 30, 40);
95 
96     private static final ZoneOffset OFFSET_P1100 = ZoneOffset.ofHours(11);
97     private static final ZoneOffset OFFSET_P1123 = ZoneOffset.ofHoursMinutes(11, 23);
98     private static final ZoneOffset OFFSET_P1023 = ZoneOffset.ofHoursMinutes(10, 23);
99     private static final ZoneOffset OFFSET_P112345 = ZoneOffset.ofHoursMinutesSeconds(11, 23, 45);
100     private static final ZoneOffset OFFSET_P100045 = ZoneOffset.ofHoursMinutesSeconds(10, 0, 45);
101     private static final ZoneOffset OFFSET_M1100 = ZoneOffset.ofHours(-11);
102     private static final ZoneOffset OFFSET_M1123 = ZoneOffset.ofHoursMinutes(-11, -23);
103     private static final ZoneOffset OFFSET_M112345 = ZoneOffset.ofHoursMinutesSeconds(-11, -23, -45);
104     private DateTimeFormatterBuilder builder;
105 
106     @BeforeMethod
setUp()107     public void setUp() {
108         builder = new DateTimeFormatterBuilder();
109     }
110 
111     //-----------------------------------------------------------------------
112     @DataProvider(name="print")
data_print()113     Object[][] data_print() {
114         return new Object[][] {
115                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
116                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
117                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01"},
118                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "Z"},
119                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01"},
120                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
121                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
122                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01"},
123                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "Z"},
124                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01"},
125                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
126 
127                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
128                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
129                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
130                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
131                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+0123"},
132                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
133                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
134                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
135                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
136                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-0123"},
137                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
138 
139                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
140                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+0100"},
141                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
142                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
143                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+0123"},
144                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
145                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-0100"},
146                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
147                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
148                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-0123"},
149                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
150 
151                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
152                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00"},
153                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
154                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
155                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23"},
156                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
157                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00"},
158                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
159                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
160                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23"},
161                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
162 
163                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
164                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+0100"},
165                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
166                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
167                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
168                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+000045"},
169                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-0100"},
170                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
171                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
172                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
173                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
174 
175                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
176                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00"},
177                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
178                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
179                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
180                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
181                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00"},
182                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
183                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
184                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
185                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
186 
187                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
188                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+010000"},
189                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+012300"},
190                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+002300"},
191                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
192                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
193                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-010000"},
194                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-012300"},
195                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-002300"},
196                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
197                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
198 
199                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
200                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00:00"},
201                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23:00"},
202                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23:00"},
203                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
204                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
205                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00:00"},
206                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23:00"},
207                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23:00"},
208                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
209                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
210 
211                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
212                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
213                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
214                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
215                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
216                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
217                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
218                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
219                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
220                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
221                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
222 
223                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
224                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
225                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
226                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
227                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
228                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+000045"},
229                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
230                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
231                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
232                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
233                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
234 
235                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
236                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
237                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1"},
238                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "Z"},
239                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1"},
240                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
241                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
242                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1"},
243                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "Z"},
244                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1"},
245                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
246 
247                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
248                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
249                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
250                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
251                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+123"},
252                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
253                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
254                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
255                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
256                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-123"},
257                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
258 
259                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
260                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+100"},
261                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
262                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
263                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+123"},
264                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
265                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-100"},
266                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
267                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
268                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-123"},
269                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
270 
271                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
272                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00"},
273                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
274                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
275                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23"},
276                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
277                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00"},
278                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
279                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
280                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23"},
281                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
282 
283                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
284                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+100"},
285                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
286                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
287                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
288                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+00045"},
289                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-100"},
290                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
291                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
292                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
293                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
294 
295                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
296                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00"},
297                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
298                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
299                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
300                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
301                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00"},
302                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
303                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
304                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
305                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
306 
307                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
308                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+10000"},
309                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+12300"},
310                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+02300"},
311                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
312                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
313                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-10000"},
314                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-12300"},
315                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-02300"},
316                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
317                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
318 
319                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
320                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00:00"},
321                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23:00"},
322                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23:00"},
323                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
324                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
325                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00:00"},
326                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23:00"},
327                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23:00"},
328                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
329                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
330 
331                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
332                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
333                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
334                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
335                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
336                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
337                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
338                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
339                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
340                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
341                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
342 
343                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
344                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
345                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
346                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
347                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
348                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+00045"},
349                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
350                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
351                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
352                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
353                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
354 
355                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
356                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11"},
357                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10"},
358                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11"},
359                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10"},
360                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
361                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11"},
362                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11"},
363 
364                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
365                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
366                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
367                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+1123"},
368                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10"},
369                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
370                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
371                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-1123"},
372 
373                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+1100"},
374                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
375                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
376                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+1123"},
377                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+1000"},
378                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-1100"},
379                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
380                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-1123"},
381 
382                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00"},
383                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
384                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
385                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23"},
386                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10:00"},
387                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00"},
388                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
389                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23"},
390 
391                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+1100"},
392                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
393                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
394                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
395                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+100045"},
396                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-1100"},
397                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
398                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
399 
400                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00"},
401                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
402                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
403                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
404                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00"},
405                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
406                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
407 
408                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+110000"},
409                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+112300"},
410                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+102300"},
411                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
412                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-110000"},
413                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-112300"},
414                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
415 
416                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00:00"},
417                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23:00"},
418                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23:00"},
419                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
420                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00:00"},
421                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23:00"},
422                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
423 
424                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
425                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
426                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
427                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
428                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
429                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
430                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
431 
432                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
433                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
434                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
435                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
436                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+100045"},
437                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
438                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
439                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
440         };
441     }
442 
443     @DataProvider(name="print_localized")
data_print_localized()444     Object[][] data_print_localized() {
445         return new Object[][] {
446                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"},
447                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+01:00"},
448                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+01:23"},
449                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+00:23"},
450                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+01:23:45"},
451                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"},
452                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-01:00"},
453                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-01:23"},
454                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-00:23"},
455                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-01:23:45"},
456                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"},
457                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"},
458                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+1"},
459                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+1:23"},
460                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+0:23"},
461                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+1:23:45"},
462                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"},
463                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-1"},
464                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-1:23"},
465                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-0:23"},
466                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-1:23:45"},
467                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"},
468         };
469     }
470 
471     @Test(dataProvider="print")
test_print(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected)472     public void test_print(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
473         ZonedDateTime zdt = ldt.atZone(zone);
474         builder.appendOffset(offsetPattern, noOffset);
475         String output = builder.toFormatter().format(zdt);
476         assertEquals(output, expected);
477     }
478 
479     //-----------------------------------------------------------------------
480     @Test(dataProvider="print")
test_print_pattern_X(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected)481     public void test_print_pattern_X(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
482         String pattern = null;
483         if (offsetPattern.equals("+HHmm") && noOffset.equals("Z")) {
484             pattern = "X";
485         } else if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
486             pattern = "XX";
487         } else if (offsetPattern.equals("+HH:MM") && noOffset.equals("Z")) {
488             pattern = "XXX";
489         } else if (offsetPattern.equals("+HHMMss") && noOffset.equals("Z")) {
490             pattern = "XXXX";
491         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
492             pattern = "XXXXX";
493         }
494         if (pattern != null) {
495             ZonedDateTime zdt = ldt.atZone(zone);
496             builder.appendPattern(pattern);
497             String output = builder.toFormatter().format(zdt);
498             assertEquals(output, expected);
499         }
500     }
501 
502     @Test(dataProvider="print")
test_print_pattern_x(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected)503     public void test_print_pattern_x(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
504         String pattern = null;
505         String zero = null;
506         if (offsetPattern.equals("+HHmm") && noOffset.equals("Z")) {
507             pattern = "x";
508             zero = "+00";
509         } else if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
510             pattern = "xx";
511             zero = "+0000";
512         } else if (offsetPattern.equals("+HH:MM") && noOffset.equals("Z")) {
513             pattern = "xxx";
514             zero = "+00:00";
515         } else if (offsetPattern.equals("+HHMMss") && noOffset.equals("Z")) {
516             pattern = "xxxx";
517             zero = "+0000";
518         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
519             pattern = "xxxxx";
520             zero = "+00:00";
521         }
522         if (pattern != null) {
523             ZonedDateTime zdt = ldt.atZone(zone);
524             builder.appendPattern(pattern);
525             String output = builder.toFormatter().format(zdt);
526             assertEquals(output, (expected.equals("Z") ? zero : expected));
527         }
528     }
529 
530     @Test(dataProvider="print")
test_print_pattern_Z(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected)531     public void test_print_pattern_Z(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
532         String pattern = null;
533         if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
534             ZonedDateTime zdt = ldt.atZone(zone);
535             DateTimeFormatter f1 = new DateTimeFormatterBuilder().appendPattern("Z").toFormatter();
536             String output1 = f1.format(zdt);
537             assertEquals(output1, (expected.equals("Z") ? "+0000" : expected));
538 
539             DateTimeFormatter f2 = new DateTimeFormatterBuilder().appendPattern("ZZ").toFormatter();
540             String output2 = f2.format(zdt);
541             assertEquals(output2, (expected.equals("Z") ? "+0000" : expected));
542 
543             DateTimeFormatter f3 = new DateTimeFormatterBuilder().appendPattern("ZZZ").toFormatter();
544             String output3 = f3.format(zdt);
545             assertEquals(output3, (expected.equals("Z") ? "+0000" : expected));
546         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
547             ZonedDateTime zdt = ldt.atZone(zone);
548             DateTimeFormatter f = new DateTimeFormatterBuilder().appendPattern("ZZZZZ").toFormatter();
549             String output = f.format(zdt);
550             assertEquals(output, expected);
551         }
552     }
553 
554     @Test(dataProvider="print_localized")
test_print_localized(TextStyle style, LocalDateTime ldt, ZoneOffset offset, String expected)555     public void test_print_localized(TextStyle style, LocalDateTime ldt, ZoneOffset offset, String expected) {
556         OffsetDateTime odt = OffsetDateTime.of(ldt, offset);
557         ZonedDateTime zdt = ldt.atZone(offset);
558 
559         DateTimeFormatter f = new DateTimeFormatterBuilder().appendLocalizedOffset(style)
560                                                             .toFormatter();
561         assertEquals(f.format(odt), expected);
562         assertEquals(f.format(zdt), expected);
563         assertEquals(f.parse(expected, ZoneOffset::from), offset);
564 
565         if (style == TextStyle.FULL) {
566             f = new DateTimeFormatterBuilder().appendPattern("ZZZZ")
567                                               .toFormatter();
568             assertEquals(f.format(odt), expected);
569             assertEquals(f.format(zdt), expected);
570             assertEquals(f.parse(expected, ZoneOffset::from), offset);
571 
572             f = new DateTimeFormatterBuilder().appendPattern("OOOO")
573                                               .toFormatter();
574             assertEquals(f.format(odt), expected);
575             assertEquals(f.format(zdt), expected);
576             assertEquals(f.parse(expected, ZoneOffset::from), offset);
577         }
578 
579         if (style == TextStyle.SHORT) {
580             f = new DateTimeFormatterBuilder().appendPattern("O")
581                                               .toFormatter();
582             assertEquals(f.format(odt), expected);
583             assertEquals(f.format(zdt), expected);
584             assertEquals(f.parse(expected, ZoneOffset::from), offset);
585         }
586     }
587 
588     //-----------------------------------------------------------------------
589     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_X6rejected()590     public void test_print_pattern_X6rejected() {
591         builder.appendPattern("XXXXXX");
592     }
593 
594     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_x6rejected()595     public void test_print_pattern_x6rejected() {
596         builder.appendPattern("xxxxxx");
597     }
598 
599     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_Z6rejected()600     public void test_print_pattern_Z6rejected() {
601         builder.appendPattern("ZZZZZZ");
602     }
603 
604     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_O2rejected()605     public void test_print_pattern_O2rejected() {
606         builder.appendPattern("OO");
607     }
608 
609     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_O3rejected()610     public void test_print_pattern_O3rejected() {
611         builder.appendPattern("OOO");
612     }
613 
614     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_O5rejected()615     public void test_print_pattern_O5rejected() {
616         builder.appendPattern("OOOOO");
617     }
618 
619     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_localzed_full_standline()620     public void test_print_pattern_localzed_full_standline() {
621         builder.appendLocalizedOffset(TextStyle.FULL_STANDALONE);
622     }
623 
624     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_localzed_short_standalone()625     public void test_print_pattern_localzed_short_standalone() {
626         builder.appendLocalizedOffset(TextStyle.SHORT_STANDALONE);
627     }
628 
629     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_localzed_narrow()630     public void test_print_pattern_localzed_narrow() {
631         builder.appendLocalizedOffset(TextStyle.NARROW);
632     }
633 
634     @Test(expectedExceptions=IllegalArgumentException.class)
test_print_pattern_localzed_narrow_standalone()635     public void test_print_pattern_localzed_narrow_standalone() {
636         builder.appendLocalizedOffset(TextStyle.NARROW_STANDALONE);
637     }
638 
639 }
640