1 /*
   2  * Copyright (c) 2007, 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  *@bug 4395196 4930708 4900884 4890240
  27  *@summary verify the ko DateFormat
  28 */
  29 
  30 import java.io.*;
  31 import java.text.*;
  32 import java.util.*;
  33 
  34 public class Bug4395196
  35 {
  36         public static void main(String[] arg)
  37         {
  38                 int result = 0;
  39                 Locale loc = new Locale("ko","KR");
  40                 Date now = new Date(108, Calendar.APRIL, 9);
  41 
  42                 DateFormat df =
  43                    DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT,loc);
  44                 SimpleDateFormat sdf = new SimpleDateFormat("",loc);
  45                 sdf.applyPattern("yyyy. M. d a h:mm");
  46                 if( !sdf.format(now).equals(df.format(now))){
  47                  result++;
  48                  System.out.println("error at " + sdf.format(now));
  49                  }
  50                 df =  DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM,loc);
  51                 sdf.applyPattern("yyyy'\ub144' M'\uc6d4' d'\uc77c' '('EE')' a h:mm:ss");
  52                 if( !sdf.format(now).equals(df.format(now))){
  53                  result++;
  54                  System.out.println("error at " + sdf.format(now));
  55                  }
  56                 df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG,loc);
  57                 sdf.applyPattern("yyyy. M. d a h'\uc2dc' mm'\ubd84' ss'\ucd08'");
  58                 if( !sdf.format(now).equals(df.format(now))){
  59                  result++;
  60                  System.out.println("error at " + sdf.format(now));
  61                  }
  62                 df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL,loc);
  63                 sdf.applyPattern("yy. M. d a h'\uc2dc' mm'\ubd84' ss'\ucd08' z");
  64                 if( !sdf.format(now).equals(df.format(now))){
  65                  result++;
  66                  System.out.println("error at " + sdf.format(now));
  67                  }
  68 
  69            if(result > 0) throw new RuntimeException();
  70 }}