Facebook
From Soft Mockingjay, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 236
  1. public static void main(String[] args) throws SQLException, ParseException {
  2.  
  3. //              List<String> list =new ArrayList<>();
  4. //        list=logOn(); //logOn trial
  5. //
  6. //        for (String s: list)
  7. //            System.out.print(s + " ");
  8. //
  9. //        ConnectDB connectDB=new ConnectDB(list);  //create connection
  10. //        list=connectDB.getList();
  11. //
  12. //        System.out.println("OUTPUT LIST :");
  13. //        for (String j:list)
  14. //            System.out.print(j + " ");
  15.  
  16.         String pesel="1611179345";
  17.  
  18.         String year=pesel.substring(0,2);
  19.         String month=pesel.substring(2,4);
  20.         String day=pesel.substring(4,6);
  21.  
  22.         Integer yearP=Integer.parseInt(year);
  23.         Integer monthP=Integer.parseInt(month);
  24.         Integer dayP=Integer.parseInt(day);
  25.  
  26.         System.out.println(yearP);
  27.         System.out.println(monthP);
  28.  
  29.         String birthDate="";
  30.         if (yearP>=0 && monthP>20 && dayP<=31){ //someone born after 2000
  31.             birthDate="20"+year+"/"+(monthP-20)+"/"+day;
  32.            // System.out.println(birthDate);
  33.         }else if(yearP>=17 && monthP<20 && dayP<=31){
  34.             birthDate="19"+year+"/"+(monthP)+"/"+day;
  35.          //   System.out.println(birthDate);
  36.         }else {
  37.             System.out.println("za stary;");
  38.         }
  39.  
  40.  
  41.         DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
  42.         Date dateb = format.parse(birthDate);
  43.         System.out.println(dateb);
  44.  
  45.        // DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
  46.         Date date = new Date();
  47.         System.out.println(format.format(date));
  48.  
  49.         long diff=date.getTime()-dateb.getTime();
  50.         long d=(1000l*60*60*24*365);
  51.         long years = Math.round(diff / d);
  52.         int age=(int) years;
  53.         System.out.println("AGE "+age);
  54.     }
  55.