List of utility methods to do String to Date
Date | strToDate(final String str) str To Date try { return DATE_FORMAT.parse(str); } catch (ParseException e) { throw new RuntimeException(e.getMessage() + " Caused by " + e.getCause(), e); |
Date | strToDate(String _date, String format) str To Date SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(_date); |
Date | strToDate(String date) str To Date java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd"); java.util.Date d = sdf.parse(date); return d; |
Date | strToDate(String date) str To Date if (date == null) { return null; Date realDate = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date newDate = sdf.parse(date); String str = sdf.format(newDate); ... |
Date | strToDate(String date, String pattern) str To Date SimpleDateFormat format = new SimpleDateFormat(pattern); try { return format.parse(date); } catch (ParseException e) { e.printStackTrace(); return null; |
Date | StrToDate(String dateFormat) Str To Date SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMM dd, yyyy HH:mm:ss a"); try { return formatter.parse(dateFormat); } catch (ParseException e) { e.printStackTrace(); return null; |
Date | strToDate(String dateInString) Convierte una fecha tipo string a un tipo Date Date newDate = null; SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); if (dateInString != null) { try { newDate = sdf.parse(dateInString); } catch (ParseException ex) { ex.printStackTrace(); return newDate; |
Date | strToDate(String dateStr, String dateFormat) str To Date if (dateStr == null || "".equals(dateStr.trim())) return null; DateFormat dt = null; if (dateFormat == null) { dt = getDateFormat(dateStr); } else { dt = new SimpleDateFormat(dateFormat); return dt.parse(dateStr); |
Date | strToDate(String dateStr, String format) str To Date SimpleDateFormat formater = new SimpleDateFormat(format); Date date = formater.parse(dateStr); return date; |
Date | strToDate(String format, String dateStr) str To Date Date date = null; try { if (yyyyMMdd.equals(format)) { date = dateFormat.parse(dateStr); } else if (yyyy_MM_dd.equals(format)) { date = dateFormat2.parse(dateStr); } else if (ddMMyy.equals(format)) { date = dateFormat3.parse(dateStr); ... |