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