List of utility methods to do String to Date
Date | stringToDate(String date) String to date. Date formattedDate = null; try { SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy"); formattedDate = sd.parse(date); } catch (ParseException e) { System.out.println("<<<<error >>>>" + e.getMessage()); e.printStackTrace(); return formattedDate; |
Date | stringToDate(String date) string To Date try { TimeZone tz = TimeZone.getDefault(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()); sdf.setTimeZone(tz); return sdf.parse(date); } catch (ParseException ex) { return null; |
Date | stringToDate(String date) string To Date Integer day = Integer.valueOf(date.split("/")[0]); String corectedDate = String.valueOf(day + 1) + "/" + date.split("/")[1] + "/" + date.split("/")[2]; SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); Date fechaDate = null; try { fechaDate = formato.parse(corectedDate); } catch (ParseException ex) { return fechaDate; |
Date | stringToDate(String date) Parse a String date into a Date object. if (date == null) { return null; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("GMT-0")); return format.parse(date); |
DateTime | stringToDate(String date) string To Date return DateTime.parse(date, magisterToDateFormatter).withZone(DateTimeZone.getDefault());
|
Date | StringToDate(String date) String To Date try { return yyyyMMdd.parse(date); } catch (ParseException e) { return new Date(); |
Date | stringToDate(String date) string To Date SimpleDateFormat sdf = new SimpleDateFormat(DATE_PARTTEN); Date d = null; try { String[] datesl = new String[3]; if (date.contains("-")) { datesl = date.split("-"); } else if (date.contains("/")) { datesl = date.split("/"); ... |
Date | stringToDate(String date) string To Date if (date == null) { return null; String separator = String.valueOf(date.charAt(4)); String pattern = "yyyyMMdd"; if (!separator.matches("\\d*")) { pattern = "yyyy" + separator + "MM" + separator + "dd"; if (date.length() < 10) { ... |
Date | stringToDate(String date, String format) string To Date Date d = null; try { SimpleDateFormat formatter = new SimpleDateFormat(format); d = formatter.parse(date); if (!formatter.format(d).equals(date)) { throw new Exception("error format date"); } catch (ParseException e) { ... |
Date | stringToDate(String date, String pattren) string To Date if (date == null || date.trim().isEmpty()) return null; if (pattren != null && !pattren.trim().isEmpty()) { DateFormat formater = new SimpleDateFormat(pattren); try { return formater.parse(date); } catch (Exception e) { e.printStackTrace(); ... |