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 data)
convert String To Date
if (data == null || data.equals(""))
    return null;
Date date = null;
try {
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    date = (java.util.Date) formatter.parse(data);
} catch (ParseException e) {
    System.err.println(e.getMessage());
...
DateconvertStringToDate(String date)
convert String To Date
String pattern = "dd/MM/yyyy HH:mm:ss";
if (date.length() <= 10) {
    date = date + " 00:00:00";
return convertStringToTime(date, pattern);
DateconvertStringToDate(String date)
convert String To Date
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
return df.parse(date);
DateconvertStringToDate(String date)
convert String To Date
try {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    SimpleDateFormat simpleDateFormatWithMs = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    String pattern = "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}";
    if (Pattern.matches(pattern, date)) {
        return simpleDateFormatWithMs.parse(date);
    return simpleDateFormat.parse(date);
...
DateconvertStringToDate(String dateAsString)
convert String To Date
SimpleDateFormat dateFormat = dateFormatBulgarian;
String dateFormatWesternPattern = "\\d{4}-\\d{2}-\\d{2}";
if (dateAsString.matches(dateFormatWesternPattern)) {
    dateFormat = dateFormatWestern;
Date date = dateFormat.parse(dateAsString);
return date;
DateconvertStringToDate(String dateFormat, String date)
convert String To Date
SimpleDateFormat sf = new SimpleDateFormat(dateFormat);
Date d = null;
if (dateFormat == null || dateFormat.trim().length() <= 0 || date == null || date.trim().length() <= 0) {
    return d;
try {
    d = sf.parse(date);
} catch (ParseException e) {
...
DateconvertStringToDate(String dateInput, String formatter)
convert String To Date
Date date = new Date();
try {
    DateFormat format = new SimpleDateFormat(formatter, Locale.ENGLISH);
    date = format.parse(dateInput);
} catch (ParseException e) {
    e.printStackTrace();
return date;
...
DateconvertStringToDate(String dateStr, String format)
convert String To Date
SimpleDateFormat sd = new SimpleDateFormat(format);
Date pasrseDate = sd.parse(dateStr);
return pasrseDate;
DateconvertStringToDate(String dateStr, String pattern)
convert String To Date
if (null == dateStr || dateStr.equals("")) {
    return null;
if (null == pattern) {
    pattern = YYYY_MM_DD_HH_MM_SS;
SimpleDateFormat sf = new SimpleDateFormat(pattern);
return sf.parse(dateStr);
...
DateconvertStringToDate(String dateString, String dateFormat)
convert String To Date
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.parse(dateString);