List of utility methods to do String to Date
Date | stringToDate(String datecontent, String format) Description:Get the date according to specific String content The default format is "yyyy-MM-dd" if (format == null || format.equals("")) format = "yyyy-MM-dd"; try { SimpleDateFormat bartDateFormat = new SimpleDateFormat(format); Date date = bartDateFormat.parse(datecontent); return date; } catch (ParseException pe) { @SuppressWarnings("unused") ... |
Date | stringToDate(String dateStr) string To Date try { if (dateStr != null) return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr); } catch (Exception e) { e.printStackTrace(); System.gc(); return null; ... |
Date | StringToDate(String dateStr) String To Date SimpleDateFormat sdf = null; Date date = null; if (dateStr.length() > 10) { if (dateStr.indexOf("T") > -1) { dateStr = dateStr.replace("T", " "); sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else { ... |
Date | stringToDate(String dateStr) Converts a String with format DateUtils.DATE_FORMAT to a Date. if (dateStr == null) return null; try { return DATE_FORMAT.parse(dateStr); } catch (ParseException ex) { return null; |
Date | stringToDate(String dateStr, SimpleDateFormat dateFormat) string To Date Date date = dateFormat.parse(dateStr);
return date;
|
java.util.Date | StringtoDate(String dateStr, String format) Stringto Date Date d = null; SimpleDateFormat formater = new SimpleDateFormat(format); try { formater.setLenient(false); d = formater.parse(dateStr); } catch (Exception e) { d = null; return d; |
Date | stringToDate(String dateString) string To Date if (dateString == null || dateString.trim().length() == 0) return null; String datestr = dateString.trim(); String sf = "yyyy-MM-dd HH:mm:ss"; Date dt = stringToDate(datestr, sf); if (dt == null) dt = stringToDate(datestr, "yyyy-MM-dd"); if (dt == null) ... |
Date | stringToDate(String dateString) String to Date. Date date = null; LinkedList<SimpleDateFormat> formats = new LinkedList<>(); formats.add(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss")); formats.add(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss")); formats.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); formats.add(new SimpleDateFormat("dd.MM.yyyy HH:mm")); for (SimpleDateFormat sdf : formats) { try { ... |
Date | stringToDate(String dateString) string To Date try { return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).parse(dateString); } catch (ParseException pex) { return new Date(0L); |
Date | stringToDate(String dateString) string To Date String sf = "yyyy-MM-dd HH:mm:ss"; Date dt = stringToDate(dateString, sf); return dt; |