List of utility methods to do String to Date
java.util.Date | strToDate(String i_StrDate, String i_Format) str To Date SimpleDateFormat SDF_My = new SimpleDateFormat(i_Format); try { return SDF_My.parse(i_StrDate); } catch (ParseException e) { throw e; |
Date | strToDate(String input, String format) str To Date try { SimpleDateFormat df = new SimpleDateFormat(format); return df.parse(input); } catch (Exception e) { return null; |
Date | strToDate(String s, Date defaultValue) Convert a 'String' to a 'Date', using DateFormat.getDateInstance().parse(s). try { return DateFormat.getDateInstance().parse(s); } catch (Exception e) { return defaultValue; |
Date | strToDate(String str) str To Date if (isEmpty(str)) { return null; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { if (str.length() != 19) { return null; return dateFormat.parse(str); } catch (ParseException e) { return null; |
java.util.Date | strToDate(String str, String format, java.util.Date defaultValue) str To Date SimpleDateFormat fmt = new SimpleDateFormat(format); try { defaultValue = fmt.parse(str); } catch (Exception localException) { return defaultValue; |
Date | strToDate(String strD) Convert string to date object try { String strFormat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(strFormat); return sdf.parse(strD); } catch (java.text.ParseException e) { return new Date(); |
Date | strToDate(String strDate) str To Date SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; |
Date | strToDate(String strDate) str To Date if (strToSimpleFormat(strDate) != null) { return strToSimpleFormat(strDate); } else { return strToDtSimpleFormat(strDate); |
Date | strToDate(String strDate) str To Date ParsePosition pos = new ParsePosition(0); return new SimpleDateFormat(FORMAT_YMD).parse(strDate, pos); |
Date | strToDate(String strDate, String format) str To Date if (strDate == null) { return null; SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; |