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