Java Utililty Methods String to Date

List of utility methods to do String to Date

Description

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

Method

DatestringToDate(String text)
string To Date
try {
    SimpleDateFormat format = new SimpleDateFormat(ISO_FORMAT);
    format.setTimeZone(UTC);
    return format.parse(text);
} catch (ParseException e) {
    return null;
DateStringToDate(String thisdate, Locale locale)
String To Date
if (thisdate == null || thisdate.trim().length() == 0) {
    return null;
SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance();
sdf.applyPattern("dd-MM-yyyy");
java.util.Date soughtDate = null;
try {
    soughtDate = sdf.parse(thisdate);
...
DatestringToDate(String time, String format)
string To Date
try {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.parse(time);
} catch (ParseException e) {
    e.printStackTrace();
    return null;
DatestringToDate(String vStr, String vPatten)
string To Date
if (vStr == null || vPatten == null) {
    throw new IllegalArgumentException("The vStr and the vPatten must not be null");
if (vStr.equals(""))
    return null;
try {
    SimpleDateFormat df = new SimpleDateFormat(vPatten);
    return df.parse(vStr);
...
DateStringToDate1(String strDate)
String To Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(strDate);
return new java.util.Date(date.getTime());
DatestringToDate10(String date)
string To Date
if (date == null || "".equals(date))
    return null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return sdf.parse(date);
DatestringToDateAndTime(final String dateAndTimeString)
Convert String ( #DATE_TIME_FORMAT ) to date and time.
DateFormat formatterDateAndTime = new SimpleDateFormat(DATE_TIME_FORMAT);
Date date = formatterDateAndTime.parse(dateAndTimeString);
return date;
DatestringToDateByconf(String str, String formate)
string To Date Byconf
DateFormat formater;
formater = new SimpleDateFormat(formate);
try {
    return (Date) formater.parse(str);
} catch (ParseException e) {
    formater = new SimpleDateFormat("yyyy-MM-dd");
    try {
        return (Date) formater.parse(str.substring(0, 10));
...
DateStringToDateByFormat(String dateStr, String formatStr)
String To Date By Format
try {
    SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
    Date date = sdf.parse(dateStr);
    return date;
} catch (Throwable t) {
    return null;
DateStringToDateByformat1(String time)
String To Date Byformat
return format1.parse(time);