1 /*
   2  * Copyright (c) 1998, 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  * @test
  26  *
  27  * @bug 4117335 4432617
  28  */
  29 
  30 import java.text.DateFormatSymbols ;
  31 import java.util.Locale;
  32 
  33 public class bug4117335 {
  34 
  35     public static void main(String[] args) throws Exception
  36     {
  37         DateFormatSymbols symbols = new DateFormatSymbols(Locale.JAPAN);
  38         String[] eras = symbols.getEras();
  39         System.out.println("BC = " + eras[0]);
  40         if (!eras[0].equals(bc)) {
  41             System.out.println("*** Should have been " + bc);
  42             throw new Exception("Error in BC");
  43         }
  44         System.out.println("AD = " + eras[1]);
  45         if (!eras[1].equals(ad)) {
  46             System.out.println("*** Should have been " + ad);
  47             throw new Exception("Error in AD");
  48         }
  49         String[][] zones = symbols.getZoneStrings();
  50         for (int i = 0; i < zones.length; i++) {
  51             if (!"Asia/Tokyo".equals(zones[i][0])) {
  52                 continue;
  53             }
  54             System.out.println("Long zone name = " + zones[i][1]);
  55             if (!zones[i][1].equals(jstLong)) {
  56                 System.out.println("*** Should have been " + jstLong);
  57                 throw new Exception("Error in long TZ name");
  58             }
  59             System.out.println("Short zone name = " + zones[i][2]);
  60             if (!zones[i][2].equals(jstShort)) {
  61                 System.out.println("*** Should have been " + jstShort);
  62                 throw new Exception("Error in short TZ name");
  63             }
  64             System.out.println("Long zone name = " + zones[i][3]);
  65             if (!zones[i][3].equals(jdtLong)) {
  66                 System.out.println("*** Should have been " + jdtLong);
  67                 throw new Exception("Error in long TZ name");
  68             }
  69             System.out.println("SHORT zone name = " + zones[i][4]);
  70             if (!zones[i][4].equals(jdtShort)) {
  71                 System.out.println("*** Should have been " + jdtShort);
  72                 throw new Exception("Error in short TZ name");
  73             }
  74         }
  75     }
  76 
  77     static final String bc = "\u7d00\u5143\u524d";
  78     static final String ad = "\u897f\u66a6";
  79     static final String jstLong = "\u65e5\u672c\u6a19\u6e96\u6642";
  80     static final String jstShort = "JST";
  81     static final String jdtLong = "\u65e5\u672c\u590f\u6642\u9593";
  82     static final String jdtShort = "JDT";
  83 }