<p>Yields the proper calendar algorithm. </p>

@param   date    historic date
@return  appropriate calendar algorithm or {@code null} if not found (in case of an invalid date)
@since   3.0
500575
Calculus getAlgorithm(HistoricDate date) {

        for (int i = this.events.size() - 1; i >= 0; i--) {
            CutOverEvent event = this.events.get(i);

            if (date.compareTo(event.dateAtCutOver) >= 0) {
                return event.algorithm;
            } else if (date.compareTo(event.dateBeforeCutOver) > 0) {
                return null; // gap at cutover
            }
        }

        return this.getJulianAlgorithm();

    }
665930
public static Calendar getCal(final Date date) {
        if (date == null) {
            return null;
        }
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return blastTime(cal);
    }
892310
public final void setDate(final Date date) {
        this.date = date;
        if (date instanceof DateTime) {
            if (Value.DATE.equals(getParameter(Parameter.VALUE))) {
                getParameters().replace(Value.DATE_TIME);
            }
            updateTimeZone(((DateTime) date).getTimeZone());
        } else {
            if (date != null) {
                getParameters().replace(Value.DATE);
            }
            /*
            else {
                getParameters().removeAll(Parameter.VALUE);
            }
            */
            // ensure timezone is null for VALUE=DATE or null properties..
            updateTimeZone(null);
        }
    }
300162
public static String formatDate(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat(TIMESTAMP_FORMAT);
        return formatter.format(date);
    }
1000839
public static boolean isDate(String date) {
        if (isEmpty(date)) return defaultEmptyOK;
        String month;
        String day;
        String year;

        int dateSlash1 = date.indexOf("/");
        int dateSlash2 = date.lastIndexOf("/");

        if (dateSlash1 <= 0 || dateSlash1 == dateSlash2) return false;
        month = date.substring(0, dateSlash1);
        day = date.substring(dateSlash1 + 1, dateSlash2);
        year = date.substring(dateSlash2 + 1);

        return isDate(year, month, day);
    }
742754
public Date toDate(Object date) {

        Date d = null;
        if (null != date) {
            if (date instanceof Date) {
                d = (Date)date;
            } else if (date instanceof Long) {
                d = new Date(((Long)date).longValue());
            } else {
                try {
                    long l = Long.parseLong(date.toString());
                    d = new Date(l);
                } catch (Exception e) {
                    // do nothing, just let d remain null
                }
            }
        }
        return d;
    }
1373418
public static Integer getDayOfWeek(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar.get(Calendar.DAY_OF_WEEK);
    }
89357
@Transformer(requireTemplate = true)
    public static String format(Date date) {
        return format(date, null, null, null);
    }
859291
public Date add(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);

		if (weeks != null) {
			int weeks = this.weeks * (prior ? -1 : 1);
			c.add(Calendar.DATE, weeks * 7);
		}
		if (days != null) {
			int days = this.days * (prior ? -1 : 1);
			c.add(Calendar.DATE, days);
		}
		if (hours != null) {
			int hours = this.hours * (prior ? -1 : 1);
			c.add(Calendar.HOUR_OF_DAY, hours);
		}
		if (minutes != null) {
			int minutes = this.minutes * (prior ? -1 : 1);
			c.add(Calendar.MINUTE, minutes);
		}
		if (seconds != null) {
			int seconds = this.seconds * (prior ? -1 : 1);
			c.add(Calendar.SECOND, seconds);
		}

		return c.getTime();
	}
478089
public static Calendar popCalendar(Date date)
   {
      Calendar calendar = popCalendar();
      calendar.setTime(date);
      return calendar;
   }
359875
public static Date getDayStartDate(Date date)
   {
      if (date != null)
      {
         Calendar cal = popCalendar(date);
         cal.set(Calendar.HOUR_OF_DAY, 0);
         cal.set(Calendar.MINUTE, 0);
         cal.set(Calendar.SECOND, 0);
         cal.set(Calendar.MILLISECOND, 0);
         date = cal.getTime();
         pushCalendar(cal);
      }
      return (date);
   }
551504
public static String dateToString(final Date date) {

        String result;
        if (date == null) {
            result = "";
        } else {
            result = Z_DATE_FORMAT.format(date);
        }
        return result;
    }
1255725
public static java.util.Date toDate(String date, String time) {
		if (date == null || time == null)
			return null;
		String month;
		String day;
		String year;
		String hour;
		String minute;
		String second;

		int dateSlash1 = date.indexOf("/");
		int dateSlash2 = date.lastIndexOf("/");

		if (dateSlash1 <= 0 || dateSlash1 == dateSlash2)
			return null;
		int timeColon1 = time.indexOf(":");
		int timeColon2 = time.lastIndexOf(":");

		if (timeColon1 <= 0)
			return null;
		month = date.substring(0, dateSlash1);
		day = date.substring(dateSlash1 + 1, dateSlash2);
		year = date.substring(dateSlash2 + 1);
		hour = time.substring(0, timeColon1);

		if (timeColon1 == timeColon2) {
			minute = time.substring(timeColon1 + 1);
			second = "0";
		} else {
			minute = time.substring(timeColon1 + 1, timeColon2);
			second = time.substring(timeColon2 + 1);
		}

		return toDate(month, day, year, hour, minute, second);
	}
118027
private static Calendar buildCalendar(final Date date) {

    Calendar calendar = buildCalendar();
    calendar.setTime(date);
    return calendar;
  }
635335
private static Calendar getCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }
390863
public static synchronized String getTime(Date date) {
		if (date == null) {
			return null;
		}
		return GET_TIME_FORMAT.format(date);
	}
336065
public static PlainDate from(GregorianDate date) {

        if (date instanceof PlainDate) {
            return (PlainDate) date;
        } else {
            return PlainDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
        }

    }