Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package batapgiuaky;
- import java.time.format.DateTimeParseException;
- import java.util.InputMismatchException;
- /**
- *
- * @author lengh
- */
- public class errorHandler {
- public static void wrongDataType(Exception e){
- if(e instanceof InputMismatchException){
- System.out.println("Nhap Sai Kieu Du Lieu");
- }
- }
- public static void wrongDateInput(Exception e){
- if(e instanceof DateTimeParseException){
- System.out.println("Ngay Thang khong hop le ");
- }
- }
- public static int CheckID(final String str) {
- String cc = str;
- if(cc == null || cc.isEmpty()) return 0;
- for(char c : cc.substring(0,2).toCharArray()){
- if(Character.isDigit(c)){
- System.out.println("Wrong Input ID");
- return 0;
- }
- }
- for(char c : str.substring(2,5).toCharArray()){
- if(!Character.isDigit(c)){
- return 0;
- }
- }
- System.out.println("OK");
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement