]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/serializable/CalendarTests.java
Added flags.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / serializable / CalendarTests.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2012, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  *
7  */
8
9 package com.ibm.icu.dev.test.serializable;
10
11 import java.util.Locale;
12
13 import com.ibm.icu.util.BuddhistCalendar;
14 import com.ibm.icu.util.Calendar;
15 import com.ibm.icu.util.ChineseCalendar;
16 import com.ibm.icu.util.CopticCalendar;
17 import com.ibm.icu.util.DangiCalendar;
18 import com.ibm.icu.util.EthiopicCalendar;
19 import com.ibm.icu.util.GregorianCalendar;
20 import com.ibm.icu.util.HebrewCalendar;
21 import com.ibm.icu.util.IndianCalendar;
22 import com.ibm.icu.util.IslamicCalendar;
23 import com.ibm.icu.util.JapaneseCalendar;
24 import com.ibm.icu.util.PersianCalendar;
25 import com.ibm.icu.util.TaiwanCalendar;
26 import com.ibm.icu.util.TimeZone;
27 import com.ibm.icu.util.ULocale;
28
29 /**
30  * @author emader
31  *
32  * TODO To change the template for this generated type comment go to
33  * Window - Preferences - Java - Code Style - Code Templates
34  */
35 public class CalendarTests
36 {
37     static class CalendarHandler implements SerializableTest.Handler
38     {
39         public Object[] getTestObjects()
40         {
41             Locale locales[] = SerializableTest.getLocales();
42             TimeZone pst = TimeZone.getTimeZone("America/Los_Angeles");
43             Calendar calendars[] = new Calendar[locales.length];
44             
45             for (int i = 0; i < locales.length; i += 1) {
46                 calendars[i] = Calendar.getInstance(pst, locales[i]);
47             }
48             
49             return calendars;
50         }
51         
52         public boolean hasSameBehavior(Object a, Object b)
53         {
54             Calendar cal_a = (Calendar) a;
55             Calendar cal_b = (Calendar) b;
56             long now = System.currentTimeMillis();
57             
58             cal_a.setTimeInMillis(now);
59             cal_a.roll(Calendar.MONTH, 1);
60             
61             cal_b.setTimeInMillis(now);
62             cal_b.roll(Calendar.MONTH, 1);
63             
64             return cal_a.getTime().equals(cal_a.getTime());
65         }
66     }
67
68     static class BuddhistCalendarHandler extends CalendarHandler
69     {
70         public Object[] getTestObjects()
71         {
72             Locale locales[] = SerializableTest.getLocales();
73             TimeZone tst = TimeZone.getTimeZone("Asia/Bangkok");
74             BuddhistCalendar calendars[] = new BuddhistCalendar[locales.length];
75             
76             for (int i = 0; i < locales.length; i += 1) {
77                 calendars[i] = new BuddhistCalendar(tst, locales[i]);
78             }
79             
80             return calendars;
81         }
82     }
83     
84     static class ChineseCalendarHandler extends CalendarHandler
85     {
86         public Object[] getTestObjects()
87         {
88             Locale locales[] = SerializableTest.getLocales();
89             TimeZone cst = TimeZone.getTimeZone("Asia/Shanghai");
90             ChineseCalendar calendars[] = new ChineseCalendar[locales.length];
91             
92             for (int i = 0; i < locales.length; i += 1) {
93                 calendars[i] = new ChineseCalendar(cst, locales[i]);
94             }
95             
96             return calendars; 
97         }
98     }
99     
100     static class CopticCalendarHandler extends CalendarHandler
101     {
102         public Object[] getTestObjects()
103         {
104             Locale locales[] = SerializableTest.getLocales();
105             TimeZone ast = TimeZone.getTimeZone("Europe/Athens");
106             CopticCalendar calendars[] = new CopticCalendar[locales.length];
107             
108             for (int i = 0; i < locales.length; i += 1) {
109                 calendars[i] = new CopticCalendar(ast, locales[i]);
110             }
111             
112             return calendars; 
113         }
114     }
115
116     static class DangiCalendarHandler extends CalendarHandler
117     {
118         public Object[] getTestObjects()
119         {
120             Locale locales[] = SerializableTest.getLocales();
121             TimeZone kst = TimeZone.getTimeZone("Asia/Seoul");
122             DangiCalendar calendars[] = new DangiCalendar[locales.length];
123             
124             for (int i = 0; i < locales.length; i += 1) {
125                 calendars[i] = new DangiCalendar(kst, ULocale.forLocale(locales[i]));
126             }
127             
128             return calendars; 
129         }
130     }
131
132     static class EthiopicCalendarHandler extends CalendarHandler
133     {
134         public Object[] getTestObjects()
135         {
136             Locale locales[] = SerializableTest.getLocales();
137             TimeZone ast = TimeZone.getTimeZone("Africa/Addis_Ababa");
138             EthiopicCalendar calendars[] = new EthiopicCalendar[locales.length];
139             
140             for (int i = 0; i < locales.length; i += 1) {
141                 calendars[i] = new EthiopicCalendar(ast, locales[i]);
142             }
143             
144             return calendars; 
145         }
146     }
147
148     static class GregorianCalendarHandler extends CalendarHandler
149     {
150         public Object[] getTestObjects()
151         {
152             Locale locales[] = SerializableTest.getLocales();
153             TimeZone pst = TimeZone.getTimeZone("America/Los_Angeles");
154             GregorianCalendar calendars[] = new GregorianCalendar[locales.length];
155             
156             for (int i = 0; i < locales.length; i += 1) {
157                 calendars[i] = new GregorianCalendar(pst, locales[i]);
158             }
159             
160             return calendars; 
161         }
162     }
163
164     static class HebrewCalendarHandler extends CalendarHandler
165     {
166         public Object[] getTestObjects()
167         {
168             Locale locales[] = SerializableTest.getLocales();
169             TimeZone jst = TimeZone.getTimeZone("Asia/Jerusalem");
170             HebrewCalendar calendars[] = new HebrewCalendar[locales.length];
171             
172             for (int i = 0; i < locales.length; i += 1) {
173                 calendars[i] = new HebrewCalendar(jst, locales[i]);
174             }
175             
176             return calendars; 
177         }
178     }
179     
180     static class IndianCalendarHandler extends CalendarHandler
181     {
182         public Object[] getTestObjects()
183         {
184             Locale locales[] = SerializableTest.getLocales();
185             TimeZone jst = TimeZone.getTimeZone("Asia/Calcutta");
186             IndianCalendar calendars[] = new IndianCalendar[locales.length];
187             
188             for (int i = 0; i < locales.length; i += 1) {
189                 calendars[i] = new IndianCalendar(jst, locales[i]);
190             }
191             
192             return calendars; 
193         }
194     }
195     
196     static class IslamicCalendarHandler extends CalendarHandler
197     {
198         public Object[] getTestObjects() {
199             Locale locales[] = SerializableTest.getLocales();
200             TimeZone cst = TimeZone.getTimeZone("Africa/Cairo");
201             IslamicCalendar calendars[] = new IslamicCalendar[locales.length];
202             
203             for (int i = 0; i < locales.length; i += 1) {
204                 calendars[i] = new IslamicCalendar(cst, locales[i]);
205             }
206             
207             return calendars; 
208         }
209     }
210
211     static class JapaneseCalendarHandler extends CalendarHandler
212     {
213         public Object[] getTestObjects()
214         {
215             Locale locales[] = SerializableTest.getLocales();
216             TimeZone jst = TimeZone.getTimeZone("Asia/Tokyo");
217             JapaneseCalendar calendars[] = new JapaneseCalendar[locales.length];
218             
219             for (int i = 0; i < locales.length; i += 1) {
220                 calendars[i] = new JapaneseCalendar(jst, locales[i]);
221             }
222             
223             return calendars; 
224         }
225     }
226
227     static class PersianCalendarHandler extends CalendarHandler
228     {
229         public Object[] getTestObjects()
230         {
231             Locale locales[] = SerializableTest.getLocales();
232             TimeZone kst = TimeZone.getTimeZone("Asia/Tehran");
233             PersianCalendar calendars[] = new PersianCalendar[locales.length];
234             
235             for (int i = 0; i < locales.length; i += 1) {
236                 calendars[i] = new PersianCalendar(kst, ULocale.forLocale(locales[i]));
237             }
238             
239             return calendars; 
240         }
241     }
242
243     static class TaiwanCalendarHandler extends CalendarHandler {
244         public Object[] getTestObjects() {
245             Locale locales[] = SerializableTest.getLocales();
246             TimeZone cst = TimeZone.getTimeZone("Asia/Shanghai");
247             TaiwanCalendar calendars[] = new TaiwanCalendar[locales.length];
248             
249             for (int i = 0; i < locales.length; i += 1) {
250                 calendars[i] = new TaiwanCalendar(cst, locales[i]);
251             }
252             
253             return calendars; 
254         }
255     }
256
257     public static void main(String[] args)
258     {
259         //nothing needed yet...
260     }
261 }