List of utility methods to do Date Parse
Date | convertStringToDate(String str_date) Convert string to date. if (str_date != null && str_date.length() == 19) return convertStringToDateWithTime(str_date); Date dt = null; SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); try { if (str_date != null) { dt = (Date) formatter.parse(str_date); } catch (ParseException e) { e.printStackTrace(); return dt; |
Date | convertStringToDate(String strDate) This method converts a String to a date using the datePattern Date aDate = null; try { aDate = convertStringToDate(datePattern, strDate); } catch (ParseException pe) { pe.printStackTrace(); return null; return aDate; ... |
Date | convertStringToDate(String strDate, String parseFormat) convert String To Date try { return new SimpleDateFormat(parseFormat).parse(strDate); } catch (Exception e) { e.printStackTrace(); return null; |
java.util.Date | convertStringToDate(String stringDate, String pattern) convert String To Date java.util.Date date = null; try { SimpleDateFormat formatter = new SimpleDateFormat(pattern); formatter.setLenient(true); date = formatter.parse(stringDate); } catch (Exception e) { date = new java.util.Date(); return date; |
long | convertStringToDate(String value) Converts the string value to date. if (value == null) { return -1L; try { return DATE_FORMAT.parse(value).getTime(); } catch (ParseException ignore) { throw new IllegalArgumentException(value); ... |
Date | convertStringToDateTimeNotException(String date) convert String To Date Time Not Exception String pattern = "dd/MM/yyyy HH:mm:ss"; try { return convertStringToTime(date, pattern); } catch (Exception e) { return null; |
Date | convertStringToDateWithRFC1123(final String dateTime) convert String To Date With RFC try { return RFC1123_DATE_FORMAT.parse(dateTime); } catch (final ParseException ex) { return DATE_MIN; |
Date | convertStringToTime(String date, String pattern) convert String To Time if (date == null || "".equals(date.trim())) { return null; SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH); return dateFormat.parse(date); |
Date | convertStringToTime(String date, String pattern) convert String To Time SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); try { return dateFormat.parse(date); } catch (ParseException e) { System.out.println("Date ParseException, string value:" + date); throw e; |
Date | convertStrToDate(String dateStr, String dateFormat) convert Str To Date if (dateStr == null || dateStr.equals("")) { return null; SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); try { return sdf.parse(dateStr); } catch (Exception e) { throw new RuntimeException("DateUtil.convertStrToDate():" + e.getMessage()); ... |