List of utility methods to do Date String Parse
String | convertDate(String YearMonthDay) convert Date String txtDate = ""; String expectedPattern = "yyyy-MM-dd"; SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern); Date date; try { date = formatter.parse(YearMonthDay); DateFormat df = new SimpleDateFormat("MMMM dd,yyyy"); txtDate = df.format(date); ... |
String | convertDateStringToDash(String MonthDayYear) convert Date String To Dash String convertedDate = ""; SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date date; try { date = formatter.parse(MonthDayYear); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); convertedDate = df.format(date); } catch (Exception e) { ... |
long | convertDateStringToLong(String date, String format) convert Date String To Long SimpleDateFormat sdf = new SimpleDateFormat(format); long time = -1; try { time = sdf.parse(date).getTime(); } catch (ParseException e) { e.printStackTrace(); return time; ... |
String | convertDateTime( String YearMonthDayHourMinuteSeconds) convert Date Time String txtDate = ""; String expectedPattern = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern); Date date; try { date = formatter.parse(YearMonthDayHourMinuteSeconds); DateFormat df = new SimpleDateFormat("MMMM dd,yyyy @ HH:mm"); txtDate = df.format(date); ... |
String | convertToDate(String dateString) convert To Date SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMMM-yy"); Date convertedDate = new Date(); try { convertedDate = dateFormat.parse(dateString); } catch (ParseException e) { e.printStackTrace(); return convertedDate.toLocaleString(); ... |
Date | getDateFromString(String format, String dateString) get Date From String SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(dateString); |
HashMap | getDateFromLJString( String dateString) get Date From LJ String final HashMap<String, Object> result = new HashMap<String, Object>(); if (dateString == null || dateString.length() == 0) { return result; final String[] dateTime = dateString.split(" "); final String[] dateItems = dateTime[0].split("-"); result.put(YEAR, dateItems[0]); result.put(MONTH, dateItems[1]); ... |
Date | getDateFromString(String dateString) get Date From String SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ss.S'Z'"); return sdf.parse(dateString); |
Date | parseRFC3339Date(String date) parse RFC Date Date result = null; SimpleDateFormat format = RFC3339Formatter.get(); boolean isLocal = date.endsWith("Z"); if (date.contains(".")) { int fracIndex = date.indexOf("."); String first = date.substring(0, fracIndex); String second = null; if (isLocal) { ... |
Date | parseRFC822Date(String date) parse RFC Date Date result = null; if (date.contains("PDT")) { date = date.replace("PDT", "PST8PDT"); if (date.contains(",")) { date = date.substring(date.indexOf(",") + 1).trim(); SimpleDateFormat format = RFC822Formatter.get(); ... |