驾驶证添加起始截止日期格式判断
This commit is contained in:
parent
7d86e5cbc6
commit
205a6ee7f5
@ -1220,14 +1220,29 @@ public class CertificatesActivity extends BaseAppCompatActivity {
|
||||
iib.setDriverLicense(str1);
|
||||
iib.setDriverLicenseBackPhoto(backId);
|
||||
iib.setDriverLicensePhoto(fontId);
|
||||
iib.setEndTime("长期".equals(odl.getData().getEndDate()) ? "2999-12-31" : odl.getData().getEndDate());
|
||||
|
||||
if ("长期".equals(odl.getData().getEndDate())){
|
||||
iib.setEndTime("2999-12-31");
|
||||
}else if (TimeUtil.isValidDate(odl.getData().getEndDate())){//非yyyy-MM-dd格式的日期传""
|
||||
iib.setEndTime(odl.getData().getEndDate());
|
||||
}else{
|
||||
iib.setEndTime("");
|
||||
}
|
||||
// iib.setEndTime("长期".equals(odl.getData().getEndDate()) ? "2999-12-31" : odl.getData().getEndDate());
|
||||
iib.setFirstTime(odl.getData().getFirstGetDocDate());
|
||||
|
||||
|
||||
// iib.setName(odl.getData().getName());
|
||||
iib.setOrganizationName(odl.getData().getIssuingAuthority());
|
||||
iib.setAddress(odl.getData().getAddress());
|
||||
iib.setStartTime(odl.getData().getBeginDate());
|
||||
|
||||
if (TimeUtil.isValidDate(odl.getData().getBeginDate())){//非yyyy-MM-dd格式的日期传""
|
||||
iib.setStartTime(odl.getData().getBeginDate());
|
||||
}else{
|
||||
iib.setStartTime("");
|
||||
}
|
||||
|
||||
// iib.setStartTime(odl.getData().getBeginDate());
|
||||
|
||||
iib.setSex(odl.getData().getSex());
|
||||
iib.setBirthday(odl.getData().getBirthday());
|
||||
|
@ -307,6 +307,27 @@ public final class TimeUtil {
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证时间字符串是否是yyyy-MM-dd格式
|
||||
*
|
||||
* @param dateStr 需要验证的时间字符串
|
||||
* @return 如果是yyyy-MM-dd格式,返回true;否则返回false
|
||||
*/
|
||||
public static boolean isValidDate(String dateStr) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
sdf.setLenient(false); // 设置不宽容,严格解析
|
||||
try {
|
||||
Date date = sdf.parse(dateStr);
|
||||
// 可以进一步验证解析后的日期是否合法(例如:检查月份天数、闰年等)
|
||||
// 但对于简单的格式验证,这一步通常不是必需的
|
||||
return true;
|
||||
} catch (ParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Date类型转为时间戳
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user