List of utility methods to do Date Parse
Date | convertStringToDate(String data) convert String To Date if (data == null || data.equals("")) return null; Date date = null; try { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date = (java.util.Date) formatter.parse(data); } catch (ParseException e) { System.err.println(e.getMessage()); ... |
Date | convertStringToDate(String date) convert String To Date String pattern = "dd/MM/yyyy HH:mm:ss"; if (date.length() <= 10) { date = date + " 00:00:00"; return convertStringToTime(date, pattern); |
Date | convertStringToDate(String date) convert String To Date DateFormat df = new SimpleDateFormat(DATE_FORMAT); return df.parse(date); |
Date | convertStringToDate(String date) convert String To Date try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); SimpleDateFormat simpleDateFormatWithMs = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); String pattern = "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}"; if (Pattern.matches(pattern, date)) { return simpleDateFormatWithMs.parse(date); return simpleDateFormat.parse(date); ... |
Date | convertStringToDate(String dateAsString) convert String To Date SimpleDateFormat dateFormat = dateFormatBulgarian; String dateFormatWesternPattern = "\\d{4}-\\d{2}-\\d{2}"; if (dateAsString.matches(dateFormatWesternPattern)) { dateFormat = dateFormatWestern; Date date = dateFormat.parse(dateAsString); return date; |
Date | convertStringToDate(String dateFormat, String date) convert String To Date SimpleDateFormat sf = new SimpleDateFormat(dateFormat); Date d = null; if (dateFormat == null || dateFormat.trim().length() <= 0 || date == null || date.trim().length() <= 0) { return d; try { d = sf.parse(date); } catch (ParseException e) { ... |
Date | convertStringToDate(String dateInput, String formatter) convert String To Date Date date = new Date(); try { DateFormat format = new SimpleDateFormat(formatter, Locale.ENGLISH); date = format.parse(dateInput); } catch (ParseException e) { e.printStackTrace(); return date; ... |
Date | convertStringToDate(String dateStr, String format) convert String To Date SimpleDateFormat sd = new SimpleDateFormat(format); Date pasrseDate = sd.parse(dateStr); return pasrseDate; |
Date | convertStringToDate(String dateStr, String pattern) convert String To Date if (null == dateStr || dateStr.equals("")) { return null; if (null == pattern) { pattern = YYYY_MM_DD_HH_MM_SS; SimpleDateFormat sf = new SimpleDateFormat(pattern); return sf.parse(dateStr); ... |
Date | convertStringToDate(String dateString, String dateFormat) convert String To Date SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.parse(dateString); |