List of utility methods to do String to Date
String | addTimeToDate(String date, int value, String unit, String sFormat) This method adds time to a given date. String sRealFormat = sFormat; if ((sRealFormat == null) || sRealFormat.equals("")) { sRealFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; SimpleDateFormat UTCFormat = new SimpleDateFormat(sRealFormat); Date dDate = new Date(); if ((date != null) && (date.length() != 0)) { try { ... |
Date | getStringToDate(String date, String format) get String To Date SimpleDateFormat simple = new SimpleDateFormat(format); try { return simple.parse(date); } catch (ParseException e) { return null; |
Date | getStringToDate(String date, String inputDateFormat) get String To Date return new SimpleDateFormat(inputDateFormat).parse(date); |
Date | getStringToDate(String pValue, String pDateFormat) get String To Date try { SimpleDateFormat formatter = new SimpleDateFormat(pDateFormat); formatter.setLenient(false); return formatter.parse(pValue); } catch (Exception e) { return null; |
Date | getStringToDate(String str) get String To Date SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date parse = null; str = str.replace("T", " "); try { parse = date.parse(str); } catch (ParseException e) { e.printStackTrace(); return parse; |
Date | getStringToDateFull(String da) get String To Date Full SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null; try { date = sdf.parse(da); } catch (ParseException e) { try { sdf = new SimpleDateFormat("yyyy-MM-dd"); date = sdf.parse(da); ... |
Date | getStringToDateTime(String dateStr, String formatStr) get String To Date Time SimpleDateFormat format = new SimpleDateFormat(formatStr); Date date = null; date = format.parse(dateStr); return date; |
String | getTodateString() get Todate String String str = yyyyMMddHH_NOT_.format(new Date()); return str; |
Date | humanDateToDate(String date) human Date To Date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(CURRENT_TIME_ZONE); return sdf.parse(date); |
String | LongToDateString(long l) Long To Date String DateFormat mediumDateFormat; Date sDate; try { mediumDateFormat = DateFormat.getDateTimeInstance(); String date = String.valueOf(l); sDate = new Date(Long.parseLong(date)); } catch (Exception ex) { ex.printStackTrace(); ... |