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

DateconvertStringToDate(String dateString, String dateFormat)
Method converts a String to Date, format of the String should be specified Example: dateString: 1999-10-15 dateFormat: yyyy-mm-dd
if (isStringBlank(dateString) || isStringBlank(dateFormat)) {
    return null;
DateFormat df = new SimpleDateFormat(dateFormat);
try {
    Date dateObject = df.parse(dateString);
    return dateObject;
} catch (ParseException e) {
...
DateconvertStringToDate(String dateString, String pattern)
convert String To Date
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.parse(dateString);
DateconvertStringToDate(String dateText)
convert String To Date
DateFormat dateFormat = new SimpleDateFormat();
try {
    return dateFormat.parse(dateText);
} catch (ParseException x) {
    throw new RuntimeException("Unable to parse string [" + dateText + "] into date.", x);
DateconvertStringToDate(String dateTime)
Converts a datetime string into and instance of java.util.Date using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.
return parseDateLoose(dateTime);
DateconvertStringToDate(String dateTime)
Converts a datetime string into and instance of java.util.Date using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.
return parseDateAsUTC(dateTime);
DateconvertStringToDate(String dt)
convert String To Date
if (dt == null || dt.equals("")) {
    return null;
return convertStringToDate("yyyy-MM-dd", dt);
DateconvertStringToDate(String input)
convert String To Date
SimpleDateFormat formatter = new SimpleDateFormat(DATEFORMAT);
Date date = null;
try {
    date = formatter.parse(input);
} catch (ParseException e) {
    e.printStackTrace(); 
return date;
...
DateconvertStringToDate(String s)
convert String To Date
try {
    SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date d;
    d = dateformat1.parse(s);
    return d;
} catch (ParseException e) {
try {
...
DateconvertStringToDate(String str)
convert String To Date
Date returnDate = null;
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
try {
    if (str != null) {
        returnDate = df.parse(str);
} catch (ParseException pe) {
    returnDate = new Date();
...
DateconvertStringToDate(String str, String pattern)
convert String To Date
SimpleDateFormat sdf = null;
try {
    sdf = new SimpleDateFormat(pattern);
} catch (Exception ex) {
    sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
    return sdf.parse(str);
...