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