Java Utililty Methods Date Parse

List of utility methods to do Date Parse

Description

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

Method

DategetDateFromStr(String inputDate, String inputFormatStr)
get Date From Str
java.text.SimpleDateFormat formatterInput = new java.text.SimpleDateFormat(inputFormatStr);
try {
    return formatterInput.parse(inputDate);
} catch (Exception e) {
    e.printStackTrace();
return null;
DategetDateFromString(final String dateStr, final String pattern)
get Date From String
final String METHOD_NAME = "getDatefromString";
final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
Date date = null;
try {
    date = dateFormat.parse(dateStr);
} catch (final Exception e) {
    e.printStackTrace();
return date;
DategetDateFromString(final String dateString, final String dateFormatString)
Takes a date in string format and a date format string and returns a Date
try {
    return parseExact(dateString, dateFormatString);
} catch (final ParseException e) {
    throw new RuntimeException("Date could not be parsed in the specified format: " + dateFormatString
            + " - " + e.getMessage());
DategetDateFromString(final String inputStringDate, final String format)
get Date From String
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
Calendar calendar = Calendar.getInstance();
try {
    calendar.setTime(dateFormat.parse(inputStringDate));
} catch (ParseException e) {
    System.err.println("Error parsing date " + e.getMessage());
    return null;
return calendar.getTime();
DategetDateFromString(String _date, String _format)
Convert a string to a specific format Date
Date _return = null;
if (_date == null) {
    return _return;
try {
    SimpleDateFormat date_format = new SimpleDateFormat(_format);
    _return = date_format.parse(_date);
} catch (java.text.ParseException e) {
...
DategetDateFromString(String date)
Parses a date string.
return sdfjd.parse(date);
DategetDateFromString(String date, String fmt)
get Date From String
if (date == null || date.trim().length() == 0)
    return null;
SimpleDateFormat sdf = fmt == null ? new SimpleDateFormat(DEFAULT_DATE_FORMAT) : new SimpleDateFormat(fmt);
return sdf.parse(date);
DategetDateFromString(String date, String pattern)
get Date From String
SimpleDateFormat sDateFormat = getDateFormat(pattern);
synchronized (sDateFormat) {
    return sDateFormat.parse(date);
DategetDatefromString(String dateStr)
convert from MMM/dd/YYYY
String actualDate = "";
String[] dates = dateStr.split("/");
System.out.println("date leng" + dates.length);
if (dates.length >= 3) {
    actualDate = dates[1] + "-" + dates[0] + "-" + dates[2];
    DateFormat mediumFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
    return mediumFormat.parse(actualDate);
return MAX_DATE;
DategetDateFromString(String dateStr, String datePattern)
For Parsing Dates.
Date date = null;
try {
    DateFormat formatter = new SimpleDateFormat(datePattern);
    date = formatter.parse(dateStr);
} catch (ParseException e) {
return date;