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