List of utility methods to do String to Date
Date | stringToDate(String text) string To Date try { SimpleDateFormat format = new SimpleDateFormat(ISO_FORMAT); format.setTimeZone(UTC); return format.parse(text); } catch (ParseException e) { return null; |
Date | StringToDate(String thisdate, Locale locale) String To Date if (thisdate == null || thisdate.trim().length() == 0) { return null; SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance(); sdf.applyPattern("dd-MM-yyyy"); java.util.Date soughtDate = null; try { soughtDate = sdf.parse(thisdate); ... |
Date | stringToDate(String time, String format) string To Date try { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(time); } catch (ParseException e) { e.printStackTrace(); return null; |
Date | stringToDate(String vStr, String vPatten) string To Date if (vStr == null || vPatten == null) { throw new IllegalArgumentException("The vStr and the vPatten must not be null"); if (vStr.equals("")) return null; try { SimpleDateFormat df = new SimpleDateFormat(vPatten); return df.parse(vStr); ... |
Date | StringToDate1(String strDate) String To Date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf.parse(strDate); return new java.util.Date(date.getTime()); |
Date | stringToDate10(String date) string To Date if (date == null || "".equals(date)) return null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); return sdf.parse(date); |
Date | stringToDateAndTime(final String dateAndTimeString) Convert String ( #DATE_TIME_FORMAT ) to date and time. DateFormat formatterDateAndTime = new SimpleDateFormat(DATE_TIME_FORMAT); Date date = formatterDateAndTime.parse(dateAndTimeString); return date; |
Date | stringToDateByconf(String str, String formate) string To Date Byconf DateFormat formater; formater = new SimpleDateFormat(formate); try { return (Date) formater.parse(str); } catch (ParseException e) { formater = new SimpleDateFormat("yyyy-MM-dd"); try { return (Date) formater.parse(str.substring(0, 10)); ... |
Date | StringToDateByFormat(String dateStr, String formatStr) String To Date By Format try { SimpleDateFormat sdf = new SimpleDateFormat(formatStr); Date date = sdf.parse(dateStr); return date; } catch (Throwable t) { return null; |
Date | StringToDateByformat1(String time) String To Date Byformat return format1.parse(time);
|