/** * Overrides TimeZone * Queries if the give date is in Daylight Saving Time. * @stable ICU 2.0 */ @Override public boolean inDaylightTime(Date date){ GregorianCalendar gc = new GregorianCalendar(this); gc.setTime(date); return gc.inDaylightTime(); }
/** * Return true if the given Date is on the same day as Easter */ @Override public boolean isOn(Date date) { synchronized(calendar) { calendar.setTime(date); int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); calendar.setTime(computeInYear(calendar.getTime(), calendar)); return calendar.get(Calendar.DAY_OF_YEAR) == dayOfYear; } }
private Date doFirstBetween(Date start, Date end) { //System.out.println("doFirstBetween: start = " + start.toString()); //System.out.println("doFirstBetween: end = " + end.toString()); synchronized(calendar) { // Figure out when this holiday lands in the given year Date result = computeInYear(start, calendar); //System.out.println(" result = " + result.toString()); // We might have gotten a date that's in the same year as "start", but // earlier in the year. If so, go to next year if (result.before(start)) { calendar.setTime(start); calendar.get(Calendar.YEAR); // JDK 1.1.2 bug workaround calendar.add(Calendar.YEAR, 1); //System.out.println(" Result before start, going to next year: " // + calendar.getTime().toString()); result = computeInYear(calendar.getTime(), calendar); //System.out.println(" result = " + result.toString()); } if (end != null && !result.before(end)) { //System.out.println("Result after end, returning null"); return null; } return result; } }
cal.setTime(date); gregorianCutoverYear = cal.get(EXTENDED_YEAR);