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

StringlongToDateString(long l)
long To Date String
Calendar c = Calendar.getInstance();
c.setTimeInMillis(l);
Date d = (Date) c.getTime();
SimpleDateFormat format = new SimpleDateFormat("MMM-dd-yyyy");
String time = format.format(d);
return time;
StringlongToDateStringDefault(long time)
long To Date String Default
return getFormatTimeString(new Date(time), "yyyyMMddHHmmss");
DatenumberToDate(String dateString)
number To Date
if ("".equals(dateString) || dateString == null) {
    return null;
Date date = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
try {
    date = simpleDateFormat.parse(dateString);
} catch (ParseException e) {
...
DateputTimeStr14ToDate(String dateTimeStr)
put Time Str To Date
Date date = null;
try {
    switch (dateTimeStr.length()) {
    case 12:
        date = yyyyMMddmmss.parse(dateTimeStr);
        break;
    case 13:
        ;
...
DateputTimeStr19ToDate(String dateTimeStr19)
put Time Str To Date
Date date = null;
try {
    date = dfyyyyMMddHHMMSS.parse(dateTimeStr19);
} catch (ParseException e) {
    e.printStackTrace();
return date;
Daterfc3339ToDate(String s)
Convert an RFC 3309 String to a Date.
s = s.toUpperCase();
Date ret = theRfc3339Format.parse(s);
return ret;
DateSortStringToDate(String thisdate, Locale locale)
Sort String To Date
return StringToDate(reformatDateString(thisdate), locale);
DatestrChangeToDate(String str)
str Change To Date
Date date = null;
try {
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
    date = sd.parse(str);
} catch (Exception e) {
    e.printStackTrace();
return date;
...
DatestrDateConvertToDate(String strDate, String fFormatStr)
str Date Convert To Date
java.util.Date birthday = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(fFormatStr);
try {
    birthday = sdf.parse(strDate);
    return birthday;
} catch (ParseException e) {
    e.printStackTrace();
    return null;
...
Date[]stringArrayTODateArray(String[] dates_s, SimpleDateFormat dateformat)
string Array TO Date Array
if (dates_s == null) {
    return null;
Date[] dates = new Date[dates_s.length];
for (int i = 0; i < dates_s.length; i++) {
    if (dateformat != null) {
        try {
            dates[i] = dateformat.parse((dates_s[i]));
...