]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/calendar/ChineseTestCase.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / calendar / ChineseTestCase.java
1 /**\r
2  *******************************************************************************\r
3  * Copyright (C) 2001-2004, International Business Machines Corporation and    *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  */\r
7 package com.ibm.icu.dev.test.calendar;\r
8 import com.ibm.icu.util.*;\r
9 import java.util.Date;\r
10 \r
11 public class ChineseTestCase extends TestCase {\r
12 \r
13     /**\r
14      * Initialize an object using a Julian day number and\r
15      * the corresponding fields for the calendar being tested.\r
16      *\r
17      * @param era the ERA field of tested calendar on the given Julian\r
18      * day\r
19      * @param year the YEAR field of tested calendar on the given\r
20      * Julian day\r
21      * @param month the MONTH (1-based) field of tested calendar on\r
22      * the given Julian day\r
23      * @param isLeapMonth if true, treat month as a leap month\r
24      * @param dayOfMonth the DAY_OF_MONTH field of tested calendar on the\r
25      * given Julian day\r
26      * @param dayOfWeek the DAY_OF_WEEK field of tested calendar on given\r
27      * Julian day\r
28      */\r
29     public ChineseTestCase(double julian,\r
30                            int era, int year, int month,\r
31                            boolean isLeapMonth, int dayOfMonth, int dayOfWeek) {\r
32 \r
33         setTime(new Date(JULIAN_EPOCH + (long)(ONE_DAY * julian)));\r
34         \r
35         set(Calendar.ERA, era);\r
36         set(Calendar.YEAR, year);\r
37         set(Calendar.MONTH, month - 1);\r
38         set(ChineseCalendar.IS_LEAP_MONTH, isLeapMonth?1:0);\r
39         set(Calendar.DAY_OF_MONTH, dayOfMonth);\r
40         set(Calendar.DAY_OF_WEEK, dayOfWeek);\r
41     }\r
42 \r
43     /**\r
44      * Return a String representation of this test case's time.\r
45      */\r
46     public String toString() {\r
47         return dowToString(get(Calendar.DAY_OF_WEEK)) +\r
48             get(Calendar.YEAR) + "of" + get(Calendar.ERA) +\r
49             "/" + (get(Calendar.MONTH)+1) +\r
50             (get(ChineseCalendar.IS_LEAP_MONTH)==1?"(leap)":"") + "/" +\r
51             get(Calendar.DAY_OF_MONTH);\r
52     }\r
53 }\r