-2
アンドロイドで私は検証を追加しようとしていますが、それは働いていません。以下は、日付のコードです。私datformatがあるアンドロイドで日付検証を受け入れる
= MM/DD/YYYY
private static final String DATE_PATTERN =
"(0?[1-9]|[12][0-9]|3[01]) [/.-] (0?[1-9]|1[012]) [/.-] ((19|20)\\d\\d)";
String getdatefor = fromDateEtxt.getText().toString();
String datefors = toDateEtxt.getText().toString();
matcher = Pattern.compile(DATE_PATTERN).matcher(getdatefor);
matchers = Pattern.compile(DATE_PATTERN).matcher(datefors);
if(matcher.matches()&&matchers.matches()){
new AsyncLoadSales().execute(getdatefor, datefors);
}
//Birthday validator
else if (!matcher.matches()){
fromDateEtxt.setError("Please Enter Valid Date");
toDateEtxt.setError("Please Enter Valid Date");
}
else{
fromDateEtxt.setError("Please Enter Valid Date");
toDateEtxt.setError("Please Enter Valid Date");
}
使用 'SimpleDateFormat' – Jens