1 7 8 package com.ibm.icu.util; 9 10 import java.util.Date ; 11 import com.ibm.icu.util.Calendar; 12 import com.ibm.icu.util.GregorianCalendar; 13 14 21 public class SimpleHoliday extends Holiday { 22 37 public SimpleHoliday(int month, int dayOfMonth, String name) 38 { 39 super(name, new SimpleDateRule(month, dayOfMonth)); 40 } 41 42 57 public SimpleHoliday(int month, int dayOfMonth, String name, 58 int startYear) 59 { 60 super(name, rangeRule(startYear, 0, new SimpleDateRule(month, dayOfMonth))); 61 } 62 63 78 public SimpleHoliday(int month, int dayOfMonth, String name, 79 int startYear, int endYear) 80 { 81 super(name, rangeRule(startYear, endYear, new SimpleDateRule(month, dayOfMonth))); 82 } 83 84 109 public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name) 110 { 111 super(name, new SimpleDateRule(month, dayOfMonth, 112 dayOfWeek > 0 ? dayOfWeek : - dayOfWeek, 113 dayOfWeek > 0)); 114 } 115 116 120 public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name, 121 int startYear) 122 { 123 super(name, rangeRule(startYear, 0, 124 new SimpleDateRule(month, dayOfMonth, 125 dayOfWeek > 0 ? dayOfWeek : - dayOfWeek, 126 dayOfWeek > 0))); 127 } 128 129 130 134 public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name, 135 int startYear, int endYear) 136 { 137 super(name, rangeRule(startYear, endYear, 138 new SimpleDateRule(month, dayOfMonth, 139 dayOfWeek > 0 ? dayOfWeek : - dayOfWeek, 140 dayOfWeek > 0))); 141 } 142 143 private static DateRule rangeRule(int startYear, int endYear, DateRule rule) 144 { 145 if (startYear == 0 && endYear == 0) { 146 return rule; 147 } 148 149 RangeDateRule rangeRule = new RangeDateRule(); 150 151 if (startYear != 0) { 152 Calendar start = new GregorianCalendar(startYear, Calendar.JANUARY, 1); 153 rangeRule.add(start.getTime(), rule); 154 } else { 155 rangeRule.add(rule); 156 } 157 if (endYear != 0) { 158 Date end = new GregorianCalendar(endYear, Calendar.DECEMBER, 31).getTime(); 159 rangeRule.add(end, null); 160 } 161 162 return rangeRule; 163 } 164 165 167 168 173 public static final SimpleHoliday NEW_YEARS_DAY = 174 new SimpleHoliday(Calendar.JANUARY, 1, "New Year's Day"); 175 176 181 public static final SimpleHoliday EPIPHANY = 182 new SimpleHoliday(Calendar.JANUARY, 6, "Epiphany"); 183 184 189 public static final SimpleHoliday MAY_DAY = 190 new SimpleHoliday(Calendar.MAY, 1, "May Day"); 191 192 197 public static final SimpleHoliday ASSUMPTION = 198 new SimpleHoliday(Calendar.AUGUST, 15, "Assumption"); 199 200 205 public static final SimpleHoliday ALL_SAINTS_DAY = 206 new SimpleHoliday(Calendar.NOVEMBER, 1, "All Saints' Day"); 207 208 213 public static final SimpleHoliday ALL_SOULS_DAY = 214 new SimpleHoliday(Calendar.NOVEMBER, 2, "All Souls' Day"); 215 216 221 public static final SimpleHoliday IMMACULATE_CONCEPTION = 222 new SimpleHoliday(Calendar.DECEMBER, 8, "Immaculate Conception"); 223 224 229 public static final SimpleHoliday CHRISTMAS_EVE = 230 new SimpleHoliday(Calendar.DECEMBER, 24, "Christmas Eve"); 231 232 237 public static final SimpleHoliday CHRISTMAS = 238 new SimpleHoliday(Calendar.DECEMBER, 25, "Christmas"); 239 240 245 public static final SimpleHoliday BOXING_DAY = 246 new SimpleHoliday(Calendar.DECEMBER, 26, "Boxing Day"); 247 248 253 public static final SimpleHoliday ST_STEPHENS_DAY = 254 new SimpleHoliday(Calendar.DECEMBER, 26, "St. Stephen's Day"); 255 256 261 public static final SimpleHoliday NEW_YEARS_EVE = 262 new SimpleHoliday(Calendar.DECEMBER, 31, "New Year's Eve"); 263 264 } 265 | Popular Tags |