1 7 8 package com.ibm.icu.util; 9 10 import java.util.Date ; 11 import java.util.Locale ; 12 import java.util.MissingResourceException ; 13 import java.util.ResourceBundle ; 14 15 20 public abstract class Holiday implements DateRule 21 { 22 26 public static Holiday[] getHolidays() 27 { 28 return getHolidays(ULocale.getDefault()); 29 } 30 31 35 public static Holiday[] getHolidays(Locale locale) 36 { 37 return getHolidays(ULocale.forLocale(locale)); 38 } 39 40 44 public static Holiday[] getHolidays(ULocale locale) 45 { 46 Holiday[] result = noHolidays; 47 48 try { 49 ResourceBundle bundle = UResourceBundle.getBundleInstance("HolidayBundle", locale); 50 51 result = (Holiday[]) bundle.getObject("holidays"); 52 } 53 catch (MissingResourceException e) { 54 } 55 return result; 56 } 57 58 70 public Date firstAfter(Date start) { 71 return rule.firstAfter(start); 72 } 73 74 88 public Date firstBetween(Date start, Date end) { 89 return rule.firstBetween(start, end); 90 } 91 92 102 public boolean isOn(Date date) { 103 return rule.isOn(date); 105 } 106 107 113 public boolean isBetween(Date start, Date end) { 114 return rule.isBetween(start, end); 115 } 116 117 131 protected Holiday(String name, DateRule rule) 132 { 133 this.name = name; 134 this.rule = rule; 135 } 136 137 142 public String getDisplayName() { 143 return getDisplayName(ULocale.getDefault()); 144 } 145 146 158 public String getDisplayName(Locale locale) 159 { 160 return getDisplayName(ULocale.forLocale(locale)); 161 } 162 163 175 public String getDisplayName(ULocale locale) 176 { 177 String name = this.name; 178 179 try { 180 ResourceBundle bundle = UResourceBundle.getBundleInstance("HolidayBundle", locale); 181 name = bundle.getString(name); 182 } 183 catch (MissingResourceException e) { 184 } 186 return name; 187 } 188 189 193 public DateRule getRule() { 194 return rule; 195 } 196 197 201 public void setRule(DateRule rule) { 202 this.rule = rule; 203 } 204 205 private String name; 206 private DateRule rule; 207 208 private static Holiday[] noHolidays = {}; 209 } 210 | Popular Tags |