List of utility methods to do Date String to Date Convert
Date | convertDateStringToDate(String dateString) convert Date String To Date SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.getDefault()); return dateFormat.parse(dateString); |
Date | string2Date(String s, String s1) string Date Date date = new Date(); try { String s2 = stringNull(s1); SimpleDateFormat simpledateformat = new SimpleDateFormat(s2); String s3 = stringNull(s); date = simpledateformat.parse(s3); } catch (Exception exception) { return date; |
Date | stringToDate(SimpleDateFormat dateFormat, String dateToConvert, boolean catchError) string To Date try { Date localDate = dateFormat.parse(dateToConvert); return localDate; } catch (Throwable localThrowable) { if (!catchError) { return new Date(1000L + System.currentTimeMillis()); return null; |
Date | stringToDate(String paramString1, String paramString2, boolean paramBoolean) string To Date SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat( paramString2, Locale.getDefault()); localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone(TimeZone .getDefault().getID())); try { Date localDate = localSimpleDateFormat.parse(paramString1); return localDate; } catch (Throwable localThrowable) { ... |
Date | toDate(String s) Parses the date string and returns the date value. Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat( "dd.MM.yyyy HH:mm:ss"); date = sdf.parse(s); } catch (ParseException e) { e.printStackTrace(); return date; |
Date | toDateFromString(String dateString) to Date From String SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a"); Date date = new Date(); try { date = sd.parse(dateString); } catch (ParseException e) { e.printStackTrace(); return date; ... |
String | str2Date(String str) str Date SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); Date date = null; try { date = (Date) sdf.parse(str); } catch (ParseException e) { e.printStackTrace(); String formatStr = new SimpleDateFormat("yy-MM-dd").format(date); return formatStr; |
String | global2Date(String str) global Date SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); Date date = null; try { date = (Date) sdf.parse(str); } catch (ParseException e) { e.printStackTrace(); String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") .format(date); System.out.println(formatStr); return formatStr; |