List of utility methods to do Date Value Check
boolean | isDate(String strDate, SimpleDateFormat sdf) is Date boolean isDate = false; try { sdf.parse(strDate); isDate = true; } catch (Exception ex) { isDate = false; return isDate; ... |
boolean | isDate(String strDate, String pattern) is Date try { parse(strDate, pattern); return true; } catch (ParseException pe) { return false; |
boolean | isDate(String strDate, String pattern) is Date SimpleDateFormat formatter = new SimpleDateFormat(pattern); formatter.setLenient(false); ParsePosition pos = new ParsePosition(0); try { Date d = formatter.parse(strDate, pos); return true; } catch (Exception e) { return false; ... |
boolean | isDate(String strDate, String pattern) is Date if (strDate == null || strDate.trim().length() <= 0) return false; try { SimpleDateFormat sdf = new SimpleDateFormat(pattern); sdf.parse(strDate); return true; } catch (ParseException e) { return false; ... |
boolean | isDate(String text, String pattern) Validation method for date. if (text == null || text.trim().isEmpty()) { return false; try { SimpleDateFormat formatter = new SimpleDateFormat(pattern); formatter.setLenient(false); formatter.parse(text); } catch (Exception e) { ... |
boolean | isDate(String val, SimpleDateFormat formatter) is Date boolean valid = true; try { Date date = formatter.parse(val); valid = null != date; } catch (Exception ex) { valid = false; return valid; ... |
boolean | isDate(String value, Locale locale) Checks if the field is a valid date. boolean bValid = true; if (value != null) { try { DateFormat formatter = null; if (locale != null) { formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale); } else { formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); ... |
boolean | isDateBefore(String date1) is Date Before try { String date2 = date1.substring(0, 10) + " 23:59:59"; DateFormat df = DateFormat.getDateTimeInstance(); return df.parse(date1).before(df.parse(date2)); } catch (ParseException e) { System.out.print("[SYS] " + e.getMessage()); return false; |
boolean | isDateBefore(String date1, String date2) is Date Before try { return stringToDate(date1, "yyyy-MM-dd HH:mm:ss").before(stringToDate(date2, "yyyy-MM-dd HH:mm:ss")); } catch (ParseException e) { System.out.print(e.getMessage()); return false; |
boolean | isDateBefore(String date1, String date2) is Date Before try { DateFormat df = DateFormat.getDateTimeInstance(); return df.parse(date1).before(df.parse(date2)); } catch (ParseException e) { return false; |