1 /*
   2  * Copyright (c) 2012, 2019, 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 import java.util.Locale;
  73 
  74 import org.testng.annotations.BeforeMethod;
  75 import org.testng.annotations.DataProvider;
  76 import org.testng.annotations.Test;
  77 
  78 /**
  79  * Test DateTimeFormatterBuilder.appendOffset().
  80  */
  81 @Test
  82 public class TCKOffsetPrinterParser {
  83 
  84     private static final LocalDateTime DT_2012_06_30_12_30_40 = LocalDateTime.of(2012, 6, 30, 12, 30, 40);
  85     
  86     private static final ZoneOffset OFFSET_UTC = ZoneOffset.UTC;
  87     private static final ZoneOffset OFFSET_P0100 = ZoneOffset.ofHours(1);
  88     private static final ZoneOffset OFFSET_P0123 = ZoneOffset.ofHoursMinutes(1, 23);
  89     private static final ZoneOffset OFFSET_P0023 = ZoneOffset.ofHoursMinutes(0, 23);
  90     private static final ZoneOffset OFFSET_P012345 = ZoneOffset.ofHoursMinutesSeconds(1, 23, 45);
  91     private static final ZoneOffset OFFSET_P000045 = ZoneOffset.ofHoursMinutesSeconds(0, 0, 45);
  92     private static final ZoneOffset OFFSET_M0100 = ZoneOffset.ofHours(-1);
  93     private static final ZoneOffset OFFSET_M0123 = ZoneOffset.ofHoursMinutes(-1, -23);
  94     private static final ZoneOffset OFFSET_M0023 = ZoneOffset.ofHoursMinutes(0, -23);
  95     private static final ZoneOffset OFFSET_M012345 = ZoneOffset.ofHoursMinutesSeconds(-1, -23, -45);
  96     private static final ZoneOffset OFFSET_M000045 = ZoneOffset.ofHoursMinutesSeconds(0, 0, -45);
  97 
  98     private static final ZoneOffset OFFSET_P1100 = ZoneOffset.ofHours(11);
  99     private static final ZoneOffset OFFSET_P1123 = ZoneOffset.ofHoursMinutes(11, 23);
 100     private static final ZoneOffset OFFSET_P1023 = ZoneOffset.ofHoursMinutes(10, 23);
 101     private static final ZoneOffset OFFSET_P112345 = ZoneOffset.ofHoursMinutesSeconds(11, 23, 45);
 102     private static final ZoneOffset OFFSET_P100045 = ZoneOffset.ofHoursMinutesSeconds(10, 0, 45);
 103     private static final ZoneOffset OFFSET_M1100 = ZoneOffset.ofHours(-11);
 104     private static final ZoneOffset OFFSET_M1123 = ZoneOffset.ofHoursMinutes(-11, -23);
 105     private static final ZoneOffset OFFSET_M112345 = ZoneOffset.ofHoursMinutesSeconds(-11, -23, -45);
 106     
 107     private static final Locale LOCALE_US = Locale.US;
 108     
 109     private DateTimeFormatterBuilder builder;
 110 
 111     @BeforeMethod
 112     public void setUp() {
 113         builder = new DateTimeFormatterBuilder();
 114     }
 115 
 116     //-----------------------------------------------------------------------
 117     @DataProvider(name="print")
 118     Object[][] data_print() {
 119         return new Object[][] {
 120                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 121                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
 122                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01"},
 123                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "Z"},
 124                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01"},
 125                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 126                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
 127                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01"},
 128                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "Z"},
 129                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01"},
 130                 {"+HH", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 131 
 132                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 133                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
 134                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
 135                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
 136                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+0123"},
 137                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 138                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
 139                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
 140                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
 141                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-0123"},
 142                 {"+HHmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 143 
 144                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 145                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+0100"},
 146                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
 147                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
 148                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+0123"},
 149                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 150                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-0100"},
 151                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
 152                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
 153                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-0123"},
 154                 {"+HHMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 155 
 156                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 157                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00"},
 158                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
 159                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
 160                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23"},
 161                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 162                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00"},
 163                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
 164                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
 165                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23"},
 166                 {"+HH:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 167 
 168                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 169                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+0100"},
 170                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
 171                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
 172                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
 173                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+000045"},
 174                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-0100"},
 175                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
 176                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
 177                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
 178                 {"+HHMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
 179 
 180                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 181                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00"},
 182                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
 183                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
 184                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
 185                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 186                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00"},
 187                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
 188                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
 189                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
 190                 {"+HH:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 191 
 192                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 193                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+010000"},
 194                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+012300"},
 195                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+002300"},
 196                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
 197                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
 198                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-010000"},
 199                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-012300"},
 200                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-002300"},
 201                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
 202                 {"+HHMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
 203 
 204                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 205                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01:00:00"},
 206                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23:00"},
 207                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23:00"},
 208                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
 209                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 210                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01:00:00"},
 211                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23:00"},
 212                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23:00"},
 213                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
 214                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 215 
 216                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 217                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
 218                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
 219                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
 220                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
 221                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 222                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
 223                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
 224                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
 225                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
 226                 {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
 227 
 228                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 229                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
 230                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
 231                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
 232                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
 233                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+000045"},
 234                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
 235                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
 236                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
 237                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
 238                 {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
 239 
 240                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 241                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
 242                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1"},
 243                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "Z"},
 244                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1"},
 245                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 246                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
 247                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1"},
 248                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "Z"},
 249                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1"},
 250                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 251 
 252                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 253                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
 254                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
 255                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
 256                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+123"},
 257                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 258                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
 259                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
 260                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
 261                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-123"},
 262                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 263 
 264                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 265                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+100"},
 266                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
 267                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
 268                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+123"},
 269                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 270                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-100"},
 271                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
 272                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
 273                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-123"},
 274                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 275 
 276                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 277                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00"},
 278                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
 279                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
 280                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23"},
 281                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "Z"},
 282                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00"},
 283                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
 284                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
 285                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23"},
 286                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "Z"},
 287 
 288                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 289                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+100"},
 290                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
 291                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
 292                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
 293                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+00045"},
 294                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-100"},
 295                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
 296                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
 297                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
 298                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
 299 
 300                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 301                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00"},
 302                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
 303                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
 304                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
 305                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 306                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00"},
 307                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
 308                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
 309                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
 310                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 311 
 312                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 313                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+10000"},
 314                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+12300"},
 315                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+02300"},
 316                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
 317                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
 318                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-10000"},
 319                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-12300"},
 320                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-02300"},
 321                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
 322                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
 323 
 324                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 325                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1:00:00"},
 326                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23:00"},
 327                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23:00"},
 328                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
 329                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 330                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1:00:00"},
 331                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23:00"},
 332                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23:00"},
 333                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
 334                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 335 
 336                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 337                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
 338                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+1:23"},
 339                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0:23"},
 340                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+1:23:45"},
 341                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 342                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
 343                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-1:23"},
 344                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0:23"},
 345                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-1:23:45"},
 346                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-0:00:45"},
 347 
 348                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
 349                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+1"},
 350                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+123"},
 351                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+023"},
 352                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+12345"},
 353                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+00045"},
 354                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-1"},
 355                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-123"},
 356                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-023"},
 357                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-12345"},
 358                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00045"},
 359 
 360                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
 361                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11"},
 362                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10"},
 363                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11"},
 364                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10"},
 365                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
 366                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11"},
 367                 {"+H", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11"},
 368 
 369                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
 370                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
 371                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
 372                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+1123"},
 373                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10"},
 374                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
 375                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
 376                 {"+Hmm", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-1123"},
 377 
 378                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+1100"},
 379                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
 380                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
 381                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+1123"},
 382                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+1000"},
 383                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-1100"},
 384                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
 385                 {"+HMM", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-1123"},
 386 
 387                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00"},
 388                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
 389                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
 390                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23"},
 391                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+10:00"},
 392                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00"},
 393                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
 394                 {"+H:MM", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23"},
 395 
 396                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+1100"},
 397                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
 398                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
 399                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
 400                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+100045"},
 401                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-1100"},
 402                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
 403                 {"+HMMss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
 404 
 405                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00"},
 406                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
 407                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
 408                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
 409                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00"},
 410                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
 411                 {"+H:MM:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
 412 
 413                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+110000"},
 414                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+112300"},
 415                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+102300"},
 416                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
 417                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-110000"},
 418                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-112300"},
 419                 {"+HMMSS", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
 420 
 421                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11:00:00"},
 422                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23:00"},
 423                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23:00"},
 424                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
 425                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11:00:00"},
 426                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23:00"},
 427                 {"+H:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
 428 
 429                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
 430                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+11:23"},
 431                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+10:23"},
 432                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+11:23:45"},
 433                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
 434                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-11:23"},
 435                 {"+H:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-11:23:45"},
 436 
 437                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1100, "+11"},
 438                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1123, "+1123"},
 439                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P1023, "+1023"},
 440                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P112345, "+112345"},
 441                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P100045, "+100045"},
 442                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1100, "-11"},
 443                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M1123, "-1123"},
 444                 {"+Hmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M112345, "-112345"},
 445         };
 446     }
 447 
 448     @DataProvider(name="print_localized")
 449     Object[][] data_print_localized() {
 450         return new Object[][] {
 451                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_UTC, LOCALE_US, "GMT"},
 452                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0100, LOCALE_US, "GMT+01:00"},
 453                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0123, LOCALE_US, "GMT+01:23"},
 454                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0023, LOCALE_US, "GMT+00:23"},
 455                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P012345, LOCALE_US, "GMT+01:23:45"},
 456                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, LOCALE_US, "GMT-00:00:45"},
 457                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0100, LOCALE_US, "GMT-01:00"},
 458                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0123, LOCALE_US, "GMT-01:23"},
 459                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0023, LOCALE_US, "GMT-00:23"},
 460                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M012345, LOCALE_US, "GMT-01:23:45"},
 461                 {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, LOCALE_US, "GMT-00:00:45"},
 462                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_UTC, LOCALE_US, "GMT"},
 463                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0100, LOCALE_US, "GMT+1"},
 464                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0123, LOCALE_US, "GMT+1:23"},
 465                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0023, LOCALE_US, "GMT+0:23"},
 466                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P012345, LOCALE_US, "GMT+1:23:45"},
 467                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, LOCALE_US, "GMT-0:00:45"},
 468                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0100, LOCALE_US, "GMT-1"},
 469                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0123, LOCALE_US, "GMT-1:23"},
 470                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0023, LOCALE_US, "GMT-0:23"},
 471                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M012345, LOCALE_US, "GMT-1:23:45"},
 472                 {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, LOCALE_US, "GMT-0:00:45"}
 473         };
 474     }
 475 
 476     @Test(dataProvider="print")
 477     public void test_print(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
 478         ZonedDateTime zdt = ldt.atZone(zone);
 479         builder.appendOffset(offsetPattern, noOffset);
 480         String output = builder.toFormatter().format(zdt);
 481         assertEquals(output, expected);
 482     }
 483 
 484     //-----------------------------------------------------------------------
 485     @Test(dataProvider="print")
 486     public void test_print_pattern_X(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
 487         String pattern = null;
 488         if (offsetPattern.equals("+HHmm") && noOffset.equals("Z")) {
 489             pattern = "X";
 490         } else if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
 491             pattern = "XX";
 492         } else if (offsetPattern.equals("+HH:MM") && noOffset.equals("Z")) {
 493             pattern = "XXX";
 494         } else if (offsetPattern.equals("+HHMMss") && noOffset.equals("Z")) {
 495             pattern = "XXXX";
 496         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
 497             pattern = "XXXXX";
 498         }
 499         if (pattern != null) {
 500             ZonedDateTime zdt = ldt.atZone(zone);
 501             builder.appendPattern(pattern);
 502             String output = builder.toFormatter().format(zdt);
 503             assertEquals(output, expected);
 504         }
 505     }
 506 
 507     @Test(dataProvider="print")
 508     public void test_print_pattern_x(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
 509         String pattern = null;
 510         String zero = null;
 511         if (offsetPattern.equals("+HHmm") && noOffset.equals("Z")) {
 512             pattern = "x";
 513             zero = "+00";
 514         } else if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
 515             pattern = "xx";
 516             zero = "+0000";
 517         } else if (offsetPattern.equals("+HH:MM") && noOffset.equals("Z")) {
 518             pattern = "xxx";
 519             zero = "+00:00";
 520         } else if (offsetPattern.equals("+HHMMss") && noOffset.equals("Z")) {
 521             pattern = "xxxx";
 522             zero = "+0000";
 523         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
 524             pattern = "xxxxx";
 525             zero = "+00:00";
 526         }
 527         if (pattern != null) {
 528             ZonedDateTime zdt = ldt.atZone(zone);
 529             builder.appendPattern(pattern);
 530             String output = builder.toFormatter().format(zdt);
 531             assertEquals(output, (expected.equals("Z") ? zero : expected));
 532         }
 533     }
 534 
 535     @Test(dataProvider="print")
 536     public void test_print_pattern_Z(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) {
 537         if (offsetPattern.equals("+HHMM") && noOffset.equals("Z")) {
 538             ZonedDateTime zdt = ldt.atZone(zone);
 539             DateTimeFormatter f1 = new DateTimeFormatterBuilder().appendPattern("Z").toFormatter();
 540             String output1 = f1.format(zdt);
 541             assertEquals(output1, (expected.equals("Z") ? "+0000" : expected));
 542 
 543             DateTimeFormatter f2 = new DateTimeFormatterBuilder().appendPattern("ZZ").toFormatter();
 544             String output2 = f2.format(zdt);
 545             assertEquals(output2, (expected.equals("Z") ? "+0000" : expected));
 546 
 547             DateTimeFormatter f3 = new DateTimeFormatterBuilder().appendPattern("ZZZ").toFormatter();
 548             String output3 = f3.format(zdt);
 549             assertEquals(output3, (expected.equals("Z") ? "+0000" : expected));
 550         } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) {
 551             ZonedDateTime zdt = ldt.atZone(zone);
 552             DateTimeFormatter f = new DateTimeFormatterBuilder().appendPattern("ZZZZZ").toFormatter();
 553             String output = f.format(zdt);
 554             assertEquals(output, expected);
 555         }
 556     }
 557 
 558     @Test(dataProvider="print_localized")
 559     public void test_print_localized(TextStyle style, LocalDateTime ldt, ZoneOffset offset, Locale locale, String expected) {
 560         
 561         OffsetDateTime odt = OffsetDateTime.of(ldt, offset);
 562         ZonedDateTime zdt = ldt.atZone(offset);
 563         
 564         builder = new DateTimeFormatterBuilder().appendLocalizedOffset(style);
 565         DateTimeFormatter f = (locale != null) ? builder.toFormatter(locale) : builder.toFormatter();
 566         assertEquals(f.format(odt), expected);
 567         assertEquals(f.format(zdt), expected);
 568         assertEquals(f.parse(expected, ZoneOffset::from), offset);
 569 
 570         if (style == TextStyle.FULL) {
 571             builder = new DateTimeFormatterBuilder().appendPattern("ZZZZ");
 572             f = (locale != null) ? builder.toFormatter(locale) : builder.toFormatter();
 573             assertEquals(f.format(odt), expected);
 574             assertEquals(f.format(zdt), expected);
 575             assertEquals(f.parse(expected, ZoneOffset::from), offset);
 576 
 577             builder = new DateTimeFormatterBuilder().appendPattern("OOOO");
 578             f = (locale != null) ? builder.toFormatter(locale) : builder.toFormatter();
 579             assertEquals(f.format(odt), expected);
 580             assertEquals(f.format(zdt), expected);
 581             assertEquals(f.parse(expected, ZoneOffset::from), offset);
 582         }
 583 
 584         if (style == TextStyle.SHORT) {
 585             builder = new DateTimeFormatterBuilder().appendPattern("O");
 586             f = (locale != null) ? builder.toFormatter(locale) : builder.toFormatter();
 587             assertEquals(f.format(odt), expected);
 588             assertEquals(f.format(zdt), expected);
 589             assertEquals(f.parse(expected, ZoneOffset::from), offset);
 590         }
 591         
 592     }
 593 
 594     //-----------------------------------------------------------------------
 595     @Test(expectedExceptions=IllegalArgumentException.class)
 596     public void test_print_pattern_X6rejected() {
 597         builder.appendPattern("XXXXXX");
 598     }
 599 
 600     @Test(expectedExceptions=IllegalArgumentException.class)
 601     public void test_print_pattern_x6rejected() {
 602         builder.appendPattern("xxxxxx");
 603     }
 604 
 605     @Test(expectedExceptions=IllegalArgumentException.class)
 606     public void test_print_pattern_Z6rejected() {
 607         builder.appendPattern("ZZZZZZ");
 608     }
 609 
 610     @Test(expectedExceptions=IllegalArgumentException.class)
 611     public void test_print_pattern_O2rejected() {
 612         builder.appendPattern("OO");
 613     }
 614 
 615     @Test(expectedExceptions=IllegalArgumentException.class)
 616     public void test_print_pattern_O3rejected() {
 617         builder.appendPattern("OOO");
 618     }
 619 
 620     @Test(expectedExceptions=IllegalArgumentException.class)
 621     public void test_print_pattern_O5rejected() {
 622         builder.appendPattern("OOOOO");
 623     }
 624 
 625     @Test(expectedExceptions=IllegalArgumentException.class)
 626     public void test_print_pattern_localzed_full_standline() {
 627         builder.appendLocalizedOffset(TextStyle.FULL_STANDALONE);
 628     }
 629 
 630     @Test(expectedExceptions=IllegalArgumentException.class)
 631     public void test_print_pattern_localzed_short_standalone() {
 632         builder.appendLocalizedOffset(TextStyle.SHORT_STANDALONE);
 633     }
 634 
 635     @Test(expectedExceptions=IllegalArgumentException.class)
 636     public void test_print_pattern_localzed_narrow() {
 637         builder.appendLocalizedOffset(TextStyle.NARROW);
 638     }
 639 
 640     @Test(expectedExceptions=IllegalArgumentException.class)
 641     public void test_print_pattern_localzed_narrow_standalone() {
 642         builder.appendLocalizedOffset(TextStyle.NARROW_STANDALONE);
 643     }
 644 
 645 }