Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/text/resources/Format/Bug4685470.java
41155 views
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 4685470
27
*@summary verify whether contain pattern for the day of week in sch and tch's default FULL pattern
28
*/
29
30
import java.util.*;
31
import java.text.*;
32
33
public class Bug4685470
34
{
35
public static void main(String args[])
36
{
37
int result = 0;
38
Bug4685470 testsuite = new Bug4685470();
39
40
if(!testsuite.TestSCH()) result ++;
41
if(!testsuite.TestTCH()) result ++;
42
43
if(result > 0) throw new RuntimeException();
44
}
45
46
private boolean TestSCH()
47
{
48
Date now = new Date();
49
DateFormat s = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.SIMPLIFIED_CHINESE);
50
51
return Test(s.format(now), getDayofWeek(now, Locale.SIMPLIFIED_CHINESE), "\"EEEE\" in " + Locale.SIMPLIFIED_CHINESE.toString());
52
}
53
54
private boolean TestTCH()
55
{
56
Date now = new Date();
57
DateFormat s = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.TRADITIONAL_CHINESE);
58
59
return Test(s.format(now), getDayofWeek(now, Locale.TRADITIONAL_CHINESE), "\"EEEE\" in " + Locale.TRADITIONAL_CHINESE.toString());
60
}
61
62
private boolean Test(String parent, String child, String patterninfo)
63
{
64
boolean result = true;
65
66
if( ! contains(parent, child)){
67
System.out.println("Full date: " + parent);
68
System.out.println("Which should contain the day of the week: " + child);
69
System.out.println("DateFormat.FULL don't contain pattern for the day of the week : " + patterninfo);
70
71
result = false;
72
}
73
74
return result;
75
}
76
77
private boolean contains(String parent, String child)
78
{
79
boolean result = false;
80
81
if(parent.length() < child.length()) result = false;
82
else {
83
for ( int i = 0; i < parent.length() - child.length(); i++){
84
result = parent.regionMatches(i, child, 0, child.length());
85
if ( result == true) break;
86
}
87
}
88
89
return result;
90
}
91
92
private String getDayofWeek(Date date, Locale loc){
93
return (new SimpleDateFormat("EEEE", loc)).format(date);
94
}
95
}
96
97