List of utility methods to do Date String to Date Convert
Date | ParseDate(String str) Parse Date SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Date addTime = null; try { addTime = dateFormat.parse(str); } catch (ParseException e) { e.printStackTrace(); return addTime; |
Date | ParseUTCDate(String str) Parse UTC Date SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ", Locale.CHINA); try { Date date = formatter.parse(str); return date; } catch (ParseException e) { try { SimpleDateFormat formatter2 = new SimpleDateFormat( ... |
String | formatToDate(String date) format To Date if (date == null) { return ""; } else { int index = date.indexOf(" "); return (index > 0 ? date.substring(0, index) : date) .replaceAll("/", "-"); |
Date | fromStringFR(String dateString) from String FR as format "dd/MM/yyyy" return fromString(dateString, DATE_FORMAT_dd_MM_yyyy);
|
Date | fromStringUS(String dateString) from String US return fromString(dateString, DATE_FORMAT_MM_dd_yyyy);
|
Date | getDateFromString(String dateString, String dateFormat) Get the Date from String with custom format. SimpleDateFormat formatter; if (dateFormat == null) { formatter = yyyyMMddFormat; } else { formatter = new SimpleDateFormat(dateFormat, Locale.ENGLISH); return formatter.parse(dateString); |
String | getDefaultDateTimeString(String date, Locale locale) get Default Date Time String try { long millis = Long.parseLong(date); return getDateTimeString(new Date(millis), DateFormat.DEFAULT, locale); } catch (Exception e) { return ""; |
String | getShortDateTimeString(String date, Locale locale) get Short Date Time String try { long millis = Long.parseLong(date); return getDateTimeString(new Date(millis), DateFormat.SHORT, locale); } catch (Exception e) { return ""; |
long | iso8601ToTimestamp(final String strDate) iso To Timestamp Date date = iso8601ToJavaDate(strDate); if (date == null) return 0; return (date.getTime() / 1000); |
long | iso8601ToTimestamp(final String strDate) iso To Timestamp Date date = iso8601ToJavaDate(strDate); if (date == null) return 0; return (date.getTime() / 1000); |