Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package batapgiuaky;
  2.  
  3. import java.time.format.DateTimeParseException;
  4. import java.util.InputMismatchException;
  5.  
  6. /**
  7.  *
  8.  * @author lengh
  9.  */
  10. public class errorHandler {
  11.     public static void wrongDataType(Exception e){
  12.         if(e instanceof InputMismatchException){
  13.             System.out.println("Nhap Sai Kieu Du Lieu");
  14.         }
  15.     }
  16.     public static void wrongDateInput(Exception e){
  17.         if(e instanceof DateTimeParseException){
  18.             System.out.println("Ngay Thang khong hop le ");
  19.         }
  20.     }
  21. public static int CheckID(final String str) {                
  22.     String cc = str;
  23.     if(cc == null || cc.isEmpty()) return 0;
  24.  
  25.     for(char c : cc.substring(0,2).toCharArray()){
  26.         if(Character.isDigit(c)){
  27.             System.out.println("Wrong Input ID");
  28.             return 0;
  29.         }
  30.     }
  31.    
  32.  
  33.     for(char c : str.substring(2,5).toCharArray()){
  34.         if(!Character.isDigit(c)){
  35.             return 0;
  36.         }
  37.            
  38.     }
  39.     System.out.println("OK");
  40.     return 1;
  41.     }
  42.    
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement