Extract a single joda date from an event date.

@param eventDate an event date from which to try to extract a DateMidnight
@return a DateMidnight or null if a date cannot be extracted
511684
public static DateMidnight extractDate(String eventDate) {
    	DateMidnight result = null;
    	DateTimeParser[] parsers = { 
    			DateTimeFormat.forPattern("yyyy-MM").getParser(),
    			DateTimeFormat.forPattern("yyyy").getParser(),
				DateTimeFormat.forPattern("yyyy-MM-dd/yyyy-MM-dd").getParser(),
    			ISODateTimeFormat.dateOptionalTimeParser().getParser(), 
    			ISODateTimeFormat.date().getParser() 
    	};
    	DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers ).toFormatter();
    	try { 
    		result = DateMidnight.parse(eventDate, formatter);
    		logger.debug(result);
    	} catch (Exception e) { 
    		// not a date
    		logger.error(e.getMessage());
    	}
    	return result;
    }
233234
public static Date localDateToDate(LocalDate localDate) {
        ZoneId zone = ZoneId.systemDefault();
        Instant instant = localDate.atStartOfDay().atZone(zone).toInstant();
        return Date.from(instant);
    }
1200267
@Nullable
  public static XMLGregorianCalendar getXMLCalendar (@Nullable final Date aDate)
  {
    if (aDate == null)
      return null;
    return s_aDTFactory.newXMLGregorianCalendar (getCalendar (aDate));
  }
743384
public static Date getStartOfWeek(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.SUNDAY);

        return calendar.getTime();
    }
1083260
@SuppressWarnings("unchecked")
    public T date( Date... date ) {
        if (checkIfNull(date)) {
            return (T) this;
        }
        date = ensureDateNotTimestamp(date);
        addObjectParameter(DATE_LIST, "date", date);
        return (T) this;
    }
1151777
public static boolean specificToDecadeScale(String eventDate) { 
    	boolean result = false;
    	if (!isEmpty(eventDate)) { 
    	    Interval eventDateInterval = extractDateInterval(eventDate);
    	    if (eventDateInterval.toDuration().getStandardDays()<=3650l) { 
    	    	result = true;
    	    }
    	}
    	return result;
    }
893499
public static Calendar calendar(Date date) {
		if(date instanceof DateTime) {
			return ((DateTime)date).toCalendar();
		}else {
			return calendar(date.getTime());
		}
	}
391526
private XMLGregorianCalendar toXMLGregorianCalendar(final DateTime date) {
        GregorianCalendar gCalendar = new GregorianCalendar(date.getZone().toTimeZone());
        gCalendar.setTime(date.toDate());
        XMLGregorianCalendar xmlGrogerianCalendar = null;
        try {
            xmlGrogerianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar);

        } catch (DatatypeConfigurationException ex) {
            log.error(ex.getMessage());
            System.out.println(ex.getStackTrace());
        }
        return xmlGrogerianCalendar;
    }
127446
public static Date beginOfDate(@NotNull final Date date) {
		return DateUtils.truncate(date, Calendar.DATE);
	}
715023
public static Date getLastDateOfMonth(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        return calendar.getTime();
    }
106840
@CheckForNull
  public static Date parseDateOrDateTime(@Nullable String stringDate) {
    if (stringDate == null) {
      return null;
    }

    OffsetDateTime odt = parseOffsetDateTimeQuietly(stringDate);
    if (odt != null) {
      return Date.from(odt.toInstant());
    }

    LocalDate ld = parseLocalDateQuietly(stringDate);
    checkArgument(ld != null, "Date '%s' cannot be parsed as either a date or date+time", stringDate);

    return Date.from(ld.atStartOfDay(ZoneId.systemDefault()).toInstant());
  }
986228
@Override
    public String getAsText() {
        DateMidnight value = (DateMidnight) getValue();
        return (value != null ? this.dateFormat.print(value) : "");
    }
935474
public static java.util.Date toJavaUtilDate(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    cal.set(date.year, date.month - 1, date.dayOfMonth);
    return cal.getTime();
  }
878295
public static final <T extends Calendar> Function<T, DateMidnight> calendarToDateMidnight(DateTimeZone dateTimeZone) {
		return FnDateMidnight.calendarToDateMidnight(dateTimeZone);
	}
27072
public static LocalDateTime dateToLocalDateTime(Date date) {

        if (date == null) {
            return null;
        }
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
    }
1150529
public static boolean specificToDay(String eventDate) { 
    	boolean result = false;
    	if (!isEmpty(eventDate)) { 
    	    Interval eventDateInterval = extractInterval(eventDate);
    	    logger.debug(eventDateInterval);
    	    logger.debug(eventDateInterval.toDuration());
    	    if (eventDateInterval.toDuration().getStandardDays()<1l) { 
    	    	result = true;
    	    } else if (eventDateInterval.toDuration().getStandardDays()==1l && eventDateInterval.getStart().getDayOfYear()==eventDateInterval.getEnd().getDayOfYear()) {
    	    	result = true;
    	    }
    	}
    	return result;
    }
1357796
public static final synchronized Date parseDate(String date) {
		try {
			return dateFormat.parse(date);
		} catch(ParseException e) {
			throw new RuntimeException(e);
		}
	}