Java Utililty Methods Date from String

List of utility methods to do Date from String

Description

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

Method

DateconvertToDate(String str, String format)
convert To Date
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.parse(str);
DateconvertToDate(String strDate, String format)
convert To Date
if (strDate == null || format == null) {
    return null;
Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
    date = sdf.parse(strDate.trim());
} catch (ParseException e) {
...
DateconvertToDate(String strDate, String format)
convert To Date
SimpleDateFormat sf = new SimpleDateFormat(format);
return sf.parse(strDate);
DateconvertToDate(String val)
convert To Date
return convertToDate(val, "yyyy-MM-dd");
DateconvertToDate(String value)
convert To Date
if (value == null)
    return null;
value = value.trim();
if (value.length() == 0)
    return null;
Date date = null;
try {
    date = FMT.parse(value);
...
DateconvertToDateTimeNoSec(String date)
convert To Date Time No Sec
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return df.parse(date);
StringconvertToDateTimeString(Date d1)
convert To Date Time String
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
String dString = df.format(d1);
return dString;
StringconvertToDateWithTimeString(Date date)
Formats a date
return DATE_WITH_TIME_FORMATTER.format(date);
DategetDateFromPattern(String pattern)
get Date From Pattern
return getDateFromPattern(pattern, new Date(System.currentTimeMillis()));
DategetDateFromReccurenceInterval(int reqDOW, int reqDOM, int time)
get Date From Reccurence Interval
Date result;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, reqDOW);
cal.set(Calendar.DAY_OF_MONTH, reqDOM);
cal.set(Calendar.HOUR_OF_DAY, time);
result = cal.getTime();
return result;