Retrieve a calendar exception which applies to this date.

@param date target date
@return calendar exception, or null if none match this date
496069
public ProjectCalendarException getException(Date date)
   {
      ProjectCalendarException exception = null;

      // We're working with expanded exceptions, which includes any recurring exceptions
      // expanded into individual entries.
      populateExpandedExceptions();
      if (!m_expandedExceptions.isEmpty())
      {
         sortExceptions();

         int low = 0;
         int high = m_expandedExceptions.size() - 1;
         long targetDate = date.getTime();

         while (low <= high)
         {
            int mid = (low + high) >>> 1;
            ProjectCalendarException midVal = m_expandedExceptions.get(mid);
            int cmp = 0 - DateHelper.compare(midVal.getFromDate(), midVal.getToDate(), targetDate);

            if (cmp < 0)
            {
               low = mid + 1;
            }
            else
            {
               if (cmp > 0)
               {
                  high = mid - 1;
               }
               else
               {
                  exception = midVal;
                  break;
               }
            }
         }
      }

      if (exception == null && getParent() != null)
      {
         // Check base calendar as well for an exception.
         exception = getParent().getException(date);
      }
      return (exception);
   }
118027
private static Calendar buildCalendar(final Date date) {

    Calendar calendar = buildCalendar();
    calendar.setTime(date);
    return calendar;
  }
269152
public static Date getFirstDateOfMonth(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));

        return calendar.getTime();
    }
126854
public static int getWeek(Date date) {
        CALENDAR.setTime(date);
        return CALENDAR.get(Calendar.DAY_OF_WEEK);
    }
405853
public static Date date(String date) {
		Date result = null;
		try {
			result = getDateFormater(DATE_FORMAT, null).parse(date);
		}
		catch (ParseException pex) {
			LOG.warn("Date not constructable {}", pex, date);
		}
		return result;
	}
474692
public static int getHour(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(Calendar.HOUR_OF_DAY);
    }
1151353
public static Integer getQuarter(Date date) {

        if (date == null)
            return null;

        int season = 1;
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int month = c.get(Calendar.MONTH);
        switch (month) {
            case Calendar.APRIL:
            case Calendar.MAY:
            case Calendar.JUNE:
                season = 2;
                break;
            case Calendar.JULY:
            case Calendar.AUGUST:
            case Calendar.SEPTEMBER:
                season = 3;
                break;
            case Calendar.OCTOBER:
            case Calendar.NOVEMBER:
            case Calendar.DECEMBER:
                season = 4;
                break;
        }
        return season;
    }
1315565
public static Date getFirstDateOfSeason(Date date) {

        if (date == null)
            return null;

        return getFirstDateOfMonth(getSeasonDate(date)[0]);
    }
798392
public String getDate(Date date) {

        return CmsDateTimeUtil.getDate(date, CmsDateTimeUtil.Format.SHORT);
    }
1358816
private @Nullable Calendar getNextItemDate(Calendar searchDate) {
        final int last = dateSpinner.getLastItemPosition();
        for (int i=0; i<=last; i++) {
            final Calendar date = ((DateItem) dateSpinner.getItemAtPosition(i)).getDate();
            // use the DateSpinner's compare method so hours and minutes are not considered
            if(DateSpinner.compareCalendarDates(date, searchDate) >= 0)
                return date;
        }
        // not found
        return null;
    }
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);
   }
632913
public static Date dateReservedMonth999(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return dateReservedMonth999(calendar);
    }
881157
public static Date getEndOfWeek(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

        return calendar.getTime();
    }
217950
public String getMealDesc(Date date)
    {
        if (m_rgstrMeals == null)
            return Constants.BLANK;

        Date startDate = this.getStartDate();
        Converter.initGlobals();    // Make sure calendars are set up
        Calendar calendar = Converter.gCalendar;
        calendar.setTime(startDate);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        startDate = calendar.getTime();
        
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        date = calendar.getTime();
        
        long lTimeToTarget = date.getTime() - startDate.getTime();
        int iTargetDay = (int)(lTimeToTarget / Constants.KMS_IN_A_DAY);   // Day 0 = first day
        if ((iTargetDay < 0) || (iTargetDay >= m_rgstrMeals.length))
            return Constants.BLANK;
        String strMeals = m_rgstrMeals[iTargetDay];
        if (strMeals == null)
            return Constants.BLANK;
        return strMeals;
    }
1214322
@Override
	public Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
		return wrapped.getDate(columnIndex, cal);
	}
1077114
public static Date parseDate(String date, String pattern) {
        try {
            return org.apache.commons.lang.time.DateUtils.parseDate(date, new String[] {pattern});
        } catch (ParseException e) {
            return null;
        }
    }
472285
public static int getDayOfWeek(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal.get(Calendar.DAY_OF_WEEK);
	}