Java Utililty Methods Parse Date

List of utility methods to do Parse Date

Description

The list of methods to do Parse Date are organized into topic(s).

Method

DateparseDate(String date)
parse Date
if (date.endsWith("Z")) {
    date = date.substring(0, date.length() - 1);
if (date.length() == 10) {
    date = date + "T00:00:00";
date = date.replaceAll("^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})$", "$1-$2-$3T$4:$5:$6");
date = date.replaceAll("^(\\d{4})(\\d{2})(\\d{2})$", "$1-$2-$3T00:00:00");
...
StringparseDate(String date)
Takes a stringified date, and returns it in xsd:date format.
StringBuilder outDate = new StringBuilder();
if (date != null) {
    DateFormat df = DateFormat.getDateInstance();
    df.setLenient(true);
    Calendar c = Calendar.getInstance();
    try {
        c.setTime(df.parse(date));
        outDate.append(c.get(Calendar.YEAR));
...
DateparseDate(String date)
parse Date
for (SimpleDateFormat pattern : knownPatterns) {
    try {
        return new Date(pattern.parse(date).getTime());
    } catch (ParseException pe) {
return null;
ArrayListparseDate(String date)
parse Date
date = date.trim();
ArrayList<Long> pdates = new ArrayList<Long>();
if (dateFormats == null) {
    dateFormats = new ArrayList<SimpleDateFormat>();
    dateFormats.add(new SimpleDateFormat("yyyy-MM-dd"));
    dateFormats.add(new SimpleDateFormat("yyyy MM dd"));
    dateFormats.add(new SimpleDateFormat("yyyy.MM.dd"));
    dateFormats.add(new SimpleDateFormat("yyyy-MMM-dd"));
...
DateparseDate(String date)
parse Date
SimpleDateFormat format = new SimpleDateFormat(common_pattern);
try {
    return format.parse(date);
} catch (Exception e) {
    e.printStackTrace();
return null;
DateparseDate(String date)
parse Date
return getDateFormat().parse(date);
DateparseDate(String date)
parse Date
return parseDate(date, "");
StringparseDate(String date, Locale locale)
parse Date
SimpleDateFormat formatter = new SimpleDateFormat("EE, dd.MM.yyyy", locale);
SimpleDateFormat destinationFormat = new SimpleDateFormat("dd.MM.yyyy", locale);
formatter.setLenient(true);
try {
    Date fDate = formatter.parse(date);
    String ret = destinationFormat.format(fDate);
    return ret;
} catch (ParseException e) {
...
DateparseDate(String date, String expression)
parse Date
try {
    if (isEmpty(expression)) {
        expression = "yyyy-MM-dd HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(expression);
    return sdf.parse(date);
} catch (Exception e) {
    return null;
...
DateparseDate(String date, String format)
parse Date
if (date == null) {
    return null;
date = date.trim();
if (date.length() == 0) {
    return null;
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
...