List of utility methods to do Year Format
boolean | isPartialYear(String s, String yearFormat) Allow only 4 digits, no more, no less int dn = 0; char[] cyear = s.toCharArray(); for (char c : cyear) { if (!Character.isDigit(c)) { return false; ++dn; if (dn != 4) { return false; String yearformat = parseDateFormat(yearFormat) + "-MM-dd"; SimpleDateFormat sdf_y = new SimpleDateFormat(yearformat); sdf_y.setLenient(false); String sy = s + "-01-18"; try { sdf_y.parse(sy); return true; } catch (Exception e) { return false; |
String | isValidDateMMddyyyy(String theString) is Valid Date M Mddyyyy String dateFormat = MMddyyyyFORMATSlashes;
String dateRegexp = MMddyyyySlashes;
return ifValidDateFormatAsyyyyMMdd(theString, dateFormat, dateRegexp);
|
boolean | isYear(int y) is Year return y >= 100 && y <= 5000;
|
boolean | isYear(String str, boolean nullCheck) is Year if (nullCheck == false || isRequired(str)) { if (str == null) { return true; if (isNumber(str, false)) { int year = Integer.parseInt(str.trim()); if (year < 1500 && year > 2999) { return false; ... |
boolean | isYearOnly(String input) is Year Only return input.matches("[0-9]{4}"); |
boolean | isYYYY(String strDate) is YYYY try { parse(strDate, YYYY); return true; } catch (ParseException pe) { return false; |
String | lastDayOfWeek(String year, int week, String format) last Day Of Week SimpleDateFormat dayFormat = new SimpleDateFormat(format, Locale.UK);
Calendar calendar = Calendar.getInstance(Locale.UK);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
calendar.set(Calendar.WEEK_OF_YEAR, week);
calendar.set(Calendar.YEAR, Integer.parseInt(year));
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
Date date = calendar.getTime();
...
|
Date | stringYYYYmmDDhhMMssToDate(String value) string YYY Ymm D Dhh M Mss To Date try { SimpleDateFormat dbUpdateDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return dbUpdateDateTime.parse(value); } catch (ParseException ex) { return null; |
String | toDateString(String ddMMMyyyy) to Date String String dateString = ""; try { Date date = new SimpleDateFormat("ddMMMyyyy", Locale.US).parse(ddMMMyyyy); dateString = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(date); } catch (Exception e) { e.printStackTrace(); return ""; return dateString; |
String | toYYYYMM(Date date) to YYYYMM return toYYYYMM(date, null);
|