Returns a Calendarobject to a given dateString in the Format 'DATEFORMAT'.
If the given String is of the wrong format, null is returned.
@see XLinkUtils#DATEFORMAT
6002
public static Calendar dateStringToCalendar(String dateString) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
        try {
            calendar.setTime(formatter.parse(dateString));
        } catch (Exception ex) {
            return null;
        }
        return calendar;
    }
1068305
public static String getCalendarJavaDateFormat(String dateFormat) {

        dateFormat = CmsStringUtil.substitute(dateFormat, "%", ""); // remove all "%"
        dateFormat = CmsStringUtil.substitute(dateFormat, "m", "${month}");
        dateFormat = CmsStringUtil.substitute(dateFormat, "H", "${hour}");
        dateFormat = CmsStringUtil.substitute(dateFormat, "Y", "${4anno}");
        dateFormat = dateFormat.toLowerCase();
        dateFormat = CmsStringUtil.substitute(dateFormat, "${month}", "M");
        dateFormat = CmsStringUtil.substitute(dateFormat, "${hour}", "H");
        dateFormat = CmsStringUtil.substitute(dateFormat, "y", "yy");
        dateFormat = CmsStringUtil.substitute(dateFormat, "${4anno}", "yyyy");
        dateFormat = CmsStringUtil.substitute(dateFormat, "m", "mm"); // minutes with two digits
        dateFormat = dateFormat.replace('e', 'd'); // day of month
        dateFormat = dateFormat.replace('i', 'h'); // 12 hour format
        dateFormat = dateFormat.replace('p', 'a'); // pm/am String
        return dateFormat;
    }
1208639
public static Date parseDate(String dateString) {
    try {
      return DATE_FORMAT.parse(dateString);
    } catch (ParseException e) {
      throw new ExchangeException("Illegal date/time format", e);
    }
  }
332668
private static Date parse(final String dateString) {
		try {
			return new SimpleDateFormat("dd/mm/yyyy").parse(dateString);
		} catch (ParseException e) {
			LOG.error("Error parsing date: " + dateString, e);
			return null;
		}
	}
544819
public void setDateFormatString(String dateFormatString) {
		if (ignoreDatePatternChange) {
			return;
		}

		try {
			dateFormatter.applyPattern(dateFormatString);
		} catch (RuntimeException e) {
			dateFormatter = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM);
			dateFormatter.setLenient(false);
		}
		this.datePattern = dateFormatter.toPattern();
		setToolTipText(this.datePattern);
		setDate(date, false);
	}
479630
public static Calendar parse(final String date, final String format) {
		return parse(date, DateTimeFormat.forPattern(format));
	}
240163
public static String getFormattedDate(final Long lastQueryDate, final String datePattern) {
        return formatDate(lastQueryDate, null, datePattern);
    }
1099738
public static Date autoParseDateFormat(String dateString) {
		// STEP 1: try to detect standard locale based java date format
		for (Locale locale : DateFormat.getAvailableLocales()) {
			for (int style = DateFormat.FULL; style <= DateFormat.SHORT; style++) {
				DateFormat df = DateFormat.getDateInstance(style, locale);
				try {
					return df.parse(dateString);
					// either return "true", or return the Date obtained Date
					// object
				} catch (ParseException ex) {
					continue; // unparsable, try the next one
				}
			}
		}

		// STEP 2: if the date format was not found, check with predefined dates
		String format = determineDateFormat(dateString);
		if (format != null) {
			DateFormat df = new SimpleDateFormat(format);
			try {
				return df.parse(dateString);
			} catch (ParseException e) {
				return null;
			}
		}
		return null;
	}
977107
public synchronized static String convertToAgmipDateString(Date date) {
        if (date != null) {
            return dateFormatter.format(date);
        } else {
            return null;
        }
    }
345343
@Override
    public Calendar convertDateToCalendar(java.util.Date date) {
        Calendar calendar = null;
        if (date != null) {
            calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.clear(Calendar.ZONE_OFFSET);
            calendar.clear(Calendar.DST_OFFSET);
        }
        return calendar;
    }
812684
private String getFormattedDate(Date date) {
		String formattedDate = "";
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		try {
			formattedDate = ValueFactoryImpl.getInstance().createValue(cal).getString();
		} catch (Exception e) {
			// should never happen
			e.printStackTrace();
		}
		return formattedDate;
	}
986228
@Override
    public String getAsText() {
        DateMidnight value = (DateMidnight) getValue();
        return (value != null ? this.dateFormat.print(value) : "");
    }
647263
private static String formatDate(Object dateObj, String format) {
		if (StrUtil.isNotBlank(format)) {
			final Date date = (dateObj instanceof Date) ? (Date)dateObj : ((Calendar)dateObj).getTime();
			//用户定义了日期格式
			return DateUtil.format(date, format);
		}
		
		//默认使用时间戳
		return String.valueOf((dateObj instanceof Date) ? ((Date)dateObj).getTime() : ((Calendar)dateObj).getTimeInMillis());
	}
1116731
private String getDateString(Date value)
   {
      Calendar cal = DateHelper.popCalendar(value);
      int year = cal.get(Calendar.YEAR);
      int month = cal.get(Calendar.MONTH) + 1;
      int day = cal.get(Calendar.DAY_OF_MONTH);
      DateHelper.pushCalendar(cal);
      
      StringBuilder sb = new StringBuilder(8);
      sb.append(m_fourDigitFormat.format(year));
      sb.append(m_twoDigitFormat.format(month));
      sb.append(m_twoDigitFormat.format(day));

      return (sb.toString());
   }
1074420
public Calendar getSortCalendar() {
        final String dateString = stripApproximationKeywords();
        if (dateString.isEmpty()) {
            return null;
        }
        return parseCalendar(dateString);
    }
294796
public String formatAsString(final String formatPattern, final Date value) {
        return format(formatPattern, value).getText();
    }
128563
static Date parseDate(String dateString) {
    try {
      return DATE_FORMAT.parseDateTime(dateString).toDate();
    } catch (IllegalArgumentException e) {
      return null;
    }
  }