List of utility methods to do String to Date
Date | stringToDate(String strDate) string To Date DateFormat df = new SimpleDateFormat(DATE_FORMAT); Date result = null; if (!isBlank(strDate)) { result = df.parse(strDate); return result; |
Date | stringToDate(String strDate) Returns date that is represented by a string. int[] diffTime = null; boolean plusTime = true; int idxT = strDate.indexOf('T'); if (idxT == -1) { throw new ParseException("Invalid Date Format", 0); int idxDiffUTC = strDate.indexOf('-', idxT); if (idxDiffUTC == -1) { ... |
Date | stringToDate(String strDate) Convert String to Date with MM/dd/yyyy format. Date date = new SimpleDateFormat("MM/dd/yyyy").parse(strDate); return date; |
Date | stringToDate(String strDate) string To Date DateFormat df = new SimpleDateFormat(PATTERN); Date date = df.parse(strDate); return date; |
Date | stringToDate(String strDate, String formartStr) string To Date Date date = null; if ((formartStr != null) && (!"".equals(formartStr))) { SimpleDateFormat sdf = new SimpleDateFormat(formartStr); try { date = sdf.parse(strDate); } catch (ParseException e) { date = null; e.printStackTrace(); ... |
Date | stringToDate(String strDate, String oracleFormat) string To Date if (strDate == null) return null; Hashtable h = new Hashtable(); String javaFormat = ""; String s = oracleFormat.toLowerCase(); if (s.indexOf("yyyy") != -1) h.put(new Integer(s.indexOf("yyyy")), "yyyy"); else if (s.indexOf("yy") != -1) ... |
Date | stringToDate(String strDate, String pattern) string To Date Date date = null; DateFormat df = new SimpleDateFormat(pattern); try { date = df.parse(strDate); } catch (ParseException e) { return null; return date; ... |
Date | stringToDate(String strDate, String strFormat) This method parses the given string to the given date format try { if (strDate == null || strDate.trim().equals("")) return null; String strDtFormat = ""; strDtFormat = strFormat.toLowerCase(); strDtFormat = replaceString(strDtFormat, "m", "M"); if (strDtFormat.indexOf("hh:MM:ss") > 0) strDtFormat = replaceString(strDtFormat, "hh:MM:ss", "HH:mm:ss"); ... |
Date | stringToDate(String string) return date value of specified string value in format: yyyy-MM-dd HH:mm:ss try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return simpleDateFormat.parse(string); } catch (Exception e) { return null; |
Date | stringToDate(String string, String format) string To Date Date dd = null; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); try { dd = simpleDateFormat.parse(string.trim()); } catch (Exception e) { dd = null; return dd; ... |