උපන් දිනේට අනුව අයිඩෙන්ටිය

Janadipathi

Banned
Mar 29, 2016
5,119
285
0
උපන් දිනේට අනුව අයිඩෙන්ටිය

උපන් දිනේට අනුව අයිඩෙන්ටි නම්බර් එක හදන ෆොමියුලා එක දන්නවද?
 

programmer98

Member
Aug 7, 2016
232
39
0
Sri Lanka


xx aaa yyyy V

xx : birth year
aaa: birth date counting from January 1st

Ex.
January 20 = (aaa) = 020
Feb 2 = (aaa) = 033
April 8 = (aaa) = 099

yyyy: unique no given.(per date)

For MALE , yyyy < 500
For FEMALE, yyyy > 500
 

Screw SL

Banned
  • Jan 4, 2013
    11,478
    718
    113
    43
    No Longer in Elakiri
    රටේ ජනාධිපති වෙලා ඕක දන්නේ නැද්ද බන්, ඔය ජනාධිපතිකම දීපන් ළමයෙක්ට
    ඔකා ඉන්තෙරුවටම ස්ටේශමක් ලග ඇත්තේ, හරීන්ගේ 100MB ෆ්‍රී වයිෆයි කැප් එකට කෙලින්න හදන්නේ ඔය.
     

    MihiCherub

    Well-known member
  • Sep 14, 2009
    18,970
    1
    9,786
    113
    Gampaha
    NEW NIC ALGORITHM JAVA 8

    අලුත් NIC එකට පොඩි කෝඩ් කෑල්ල්ක් ලිව්ව. උබලට ඕනෙ විදියට වෙනස් කරගෙන පොඩ්ඩක් ටෙස්ට් කොරල බලල කියපල්ල හරිද කියල. උබලට ඕනෙ ප්‍රොජෙක්ට් වලින් ගෙඩිය පිටින්ම උස්සල පාවිච්චි කරපල්ල. :rofl: JAVA 8 එක්ක මහලොකු වෙලාවක් යන්නෙ නෑ. :D

    Code:
    import java.time.LocalDate;
    import java.time.Period;
    import java.time.temporal.ChronoUnit;
    
    /**
     *
     * @author Tharindu
     */
    public class NicDetails {
    
        private String birthDay, gender, fullAge;
        private int age;
    
        public NicDetails(String nic) {
            setDetails(nic);
        }
    
        public String getBirthDay() {
            return birthDay;
        }
    
        public int getAge() {
            return age;
        }
    
        public String getGender() {
            return gender;
        }
    
        public String getFullAge() {
            return fullAge;
        }
    
        public static void main(String[] args) {
            NicDetails nicDetails = new NicDetails("960621025v");
            System.out.println(nicDetails.getBirthDay());
            System.out.println(nicDetails.getGender());
            System.out.println(nicDetails.getAge());
            System.out.println(nicDetails.getFullAge());
        }
    
        private void setDetails(String nic) {
            int year, days;
            if (nic.length() == 10) {   //OLD NIC-----------------------------------
                year = Integer.parseInt("19" + nic.substring(0, 2));
                days = Integer.parseInt(nic.substring(2, 5));
            } else {                    //NEW NIC-----------------------------------
                year = Integer.parseInt(nic.substring(0, 4));
                days = Integer.parseInt(nic.substring(4, 7));
            }
            if (days > 500) {
                setGender("Female");
                days -= 500;
            } else {
                setGender("Male");
            }
    
            LocalDate date = LocalDate.ofYearDay(year, days);
            if (!date.isLeapYear() && days > 60) {
                date = date.plusDays(-1);
            }
            setBirthDay(date.toString());
    
            //AGE-------------------------------------------------------------------
            int oldYear = (int) ChronoUnit.YEARS.between(date, LocalDate.now());
            setAge(oldYear);
    
            Period elapsed = Period.between(date, LocalDate.now());
    
            String text = oldYear + " years " + elapsed.getMonths() + " month(s) " + elapsed.getDays() + " day(s)";
            setFullAge(text);
    
        }
    
        /**
         * @param birthDay the birthDay to set
         */
        private void setBirthDay(String birthDay) {
            this.birthDay = birthDay;
        }
    
        /**
         * @param gender the gender to set
         */
        private void setGender(String gender) {
            this.gender = gender;
        }
    
        /**
         * @param fullAge the fullAge to set
         */
        private void setFullAge(String fullAge) {
            this.fullAge = fullAge;
        }
    
        /**
         * @param age the age to set
         */
        private void setAge(int age) {
            this.age = age;
        }
    }


    https://en.wikipedia.org/wiki/National_identity_card_(Sri_Lanka)
    http://www.elakiri.com/forum/showthread.php?p=19897833#post19897833NEW NIC ALGORITHM JAVA 8
    http://www.elakiri.com/forum/newreply.php?do=newreply&p=19897833
     

    Screw SL

    Banned
  • Jan 4, 2013
    11,478
    718
    113
    43
    No Longer in Elakiri
    11.gif