/** * 校验输入日期值是否符合指定的格式,是否在设定的区域内。 * 如:指定日期格式DateFromat为"yyyy-MM-dd",如果输入的日期值格式不符合,则不合法; * 若同时指定了最小值为"2000-12-31",最大值为"2005-12-31",而输入的日期不在此区间 内,则不合法;也可以只指定其中的某一个 */ @Override protected boolean validate(Context context, String value) { DateFormat format = getDateFormat(); Date inputDate; try { inputDate = format.parse(value); } catch (ParseException e) { return false; } if (minDate != null && inputDate.before(minDate)) { return false; } if (maxDate != null && inputDate.after(maxDate)) { return false; } return true; }
/** * 校验输入日期值是否符合指定的格式,是否在设定的区域内。 * 如:指定日期格式DateFromat为"yyyy-MM-dd",如果输入的日期值格式不符合,则不合法; * 若同时指定了最小值为"2000-12-31",最大值为"2005-12-31",而输入的日期不在此区间 内,则不合法;也可以只指定其中的某一个 */ @Override protected boolean validate(Context context, String value) { DateFormat format = getDateFormat(); Date inputDate; try { inputDate = format.parse(value); } catch (ParseException e) { return false; } if (minDate != null && inputDate.before(minDate)) { return false; } if (maxDate != null && inputDate.after(maxDate)) { return false; } return true; }
@Override protected void init() throws Exception { super.init(); if (dateFormatStr == null) { dateFormatStr = DEFAULT_DATE_FORMAT; } DateFormat format = getDateFormat(); if (minDateStr != null) { minDate = format.parse(minDateStr); minDateStr = format.format(minDate); } if (maxDateStr != null) { maxDate = format.parse(maxDateStr); maxDateStr = format.format(maxDate); } }
@Override protected void init() throws Exception { super.init(); if (dateFormatStr == null) { dateFormatStr = DEFAULT_DATE_FORMAT; } DateFormat format = getDateFormat(); if (minDateStr != null) { minDate = format.parse(minDateStr); minDateStr = format.format(minDate); } if (maxDateStr != null) { maxDate = format.parse(maxDateStr); maxDateStr = format.format(maxDate); } }
/** * 校验输入日期值是否符合指定的格式,是否在设定的区域内。 * 如:指定日期格式DateFromat为"yyyy-MM-dd",如果输入的日期值格式不符合,则不合法; * 若同时指定了最小值为"2000-12-31",最大值为"2005-12-31",而输入的日期不在此区间 内,则不合法;也可以只指定其中的某一个 */ @Override protected boolean validate(Context context, String value) { DateFormat format = getDateFormat(); Date inputDate; try { inputDate = format.parse(value); } catch (ParseException e) { return false; } if (minDate != null && inputDate.before(minDate)) { return false; } if (maxDate != null && inputDate.after(maxDate)) { return false; } return true; }
@Override protected void init() throws Exception { super.init(); if (dateFormatStr == null) { dateFormatStr = DEFAULT_DATE_FORMAT; } DateFormat format = getDateFormat(); if (minDateStr != null) { minDate = format.parse(minDateStr); minDateStr = format.format(minDate); } if (maxDateStr != null) { maxDate = format.parse(maxDateStr); maxDateStr = format.format(maxDate); } }