List of utility methods to do String to Date
Date | toDate(final String _text, final String _dateFormat) Convert a string into a date type. SimpleDateFormat formatter = new SimpleDateFormat(_dateFormat); try { return formatter.parse(_text); } catch (ParseException ex) { throw new RuntimeException(ex); |
Date | toDate(final String date, final String time) to Date try { return new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(date + " " + time); } catch (ParseException e) { throw new RuntimeException(e); |
Date | toDate(final String dateString, final String format) to Date if (dateString == null || dateString.isEmpty()) { return null; final SimpleDateFormat sdf = getSimpleDateFormat(format); Date date = null; if (dateString != null) { date = sdf.parse(dateString); return date; |
Date | toDate(final String dateString, final String pattern) to Date final SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { return sdf.parse(dateString); } catch (final Exception e) { return null; |
Date | toDate(int date, String timeFormat) to Date StringBuilder sbBuilder = new StringBuilder(); if (!yyyyMMdd.equals(timeFormat) && String.valueOf(date).length() == 8) { sbBuilder.append("0"); sbBuilder.append(date); DateFormat sdf = new SimpleDateFormat(timeFormat); Date datetime = new Date(); try { ... |
Date | toDate(long value, String format) to Date SimpleDateFormat fmt = new SimpleDateFormat(format); Date date = null; try { date = fmt.parse(Long.toString(value)); } catch (ParseException e) { e.printStackTrace(); return date; ... |
Map | toDate(Map to Date return toDate(filter, field, null, MODO_NOP);
|
Date | toDate(Object v, String format, Date defaultValue) to Date if (v == null) { return defaultValue; } else { if (v instanceof Date) { return (Date) v; } else if (v.getClass() == Long.class || v.getClass() == long.class) { return new Date((Long) v); } else { ... |
Date | toDate(Object value, String format) Convert the specified object into a Date. if (value == null) return null; if (value instanceof String) { try { return new SimpleDateFormat(format).parse((String) value); } catch (ParseException e) { throw new RuntimeException( "The value " + value + "with format " + format + " can't be converted to a Date", e); ... |
Date | toDate(String createdAt) to Date try { return createLocalFormat().parse(createdAt); } catch (ParseException ex) { throw new RuntimeException(ex); |