List of utility methods to do Date Format Check
boolean | checkDateInToday(Date date) check Date In Today if (date == null) { return true; boolean flag = false; Date now = new Date(); String nowStr = dateToString(now, "yyyy-MM-dd"); String dateStr = dateToString(date, "yyyy-MM-dd"); if (!nowStr.equals(dateStr)) { ... |
boolean | checkDateRange(String fromDate, String endDate) Check between date range. long fromTime = transDate(fromDate, "yyyy-MM-dd").getTime(); long endTime = transDate(endDate, "yyyy-MM-dd").getTime(); long todayTime = transDate(getDate(), "yyyy-MM-dd").getTime(); if (fromTime <= todayTime && todayTime <= endTime) { return true; return false; |
boolean | checkDateValidity(String str, String formatString) check Date Validity SimpleDateFormat sdf = new SimpleDateFormat(formatString); sdf.setLenient(false); try { sdf.parse(str); return true; } catch (ParseException e) { return false; |
String | checkTime(int id) Check time. String bol = ""; Calendar tt = Calendar.getInstance(); String currDate = getNowDate(); System.out.println("currDate=" + currDate); int result = tt.get(Calendar.DAY_OF_WEEK); int shour = tt.get(Calendar.HOUR_OF_DAY); if (id == 3) { switch (result) { ... |
boolean | checkTimestamp(String timestamp) check Timestamp SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); Date time = null; try { time = dateFormat.parse(timestamp); } catch (ParseException e) { System.out.println("Timestamp check error"); e.printStackTrace(); System.exit(-1); ... |