Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
NEW NIC ALGORITHM JAVA 8
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MihiCherub" data-source="post: 19897833" data-attributes="member: 238676"><p><strong>NEW NIC ALGORITHM JAVA 8 </strong></p><p><strong></strong></p><p><strong></strong><span style="font-size: 12px">අලුත් NIC එකට පොඩි කෝඩ් කෑල්ල්ක් ලිව්ව. උබලට ඕනෙ විදියට වෙනස් කරගෙන පොඩ්ඩක් ටෙස්ට් කොරල බලල කියපල්ල හරිද කියල. උබලට ඕනෙ ප්රොජෙක්ට් වලින් ගෙඩිය පිටින්ම උස්සල පාවිච්චි කරපල්ල. <img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /> JAVA 8 එක්ක මහලොකු වෙලාවක් යන්නෙ නෑ. <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span>[CODE]import java.time.LocalDate;</p><p>import java.time.Period;</p><p>import java.time.temporal.ChronoUnit;</p><p></p><p>/**</p><p> *</p><p> * @author Tharindu</p><p> */</p><p>public class NicDetails {</p><p></p><p> private String birthDay, gender, fullAge;</p><p> private int age;</p><p></p><p> public NicDetails(String nic) {</p><p> setDetails(nic);</p><p> }</p><p></p><p> public String getBirthDay() {</p><p> return birthDay;</p><p> }</p><p></p><p> public int getAge() {</p><p> return age;</p><p> }</p><p></p><p> public String getGender() {</p><p> return gender;</p><p> }</p><p></p><p> public String getFullAge() {</p><p> return fullAge;</p><p> }</p><p></p><p> public static void main(String[] args) {</p><p> NicDetails nicDetails = new NicDetails("960621025v");</p><p> System.out.println(nicDetails.getBirthDay());</p><p> System.out.println(nicDetails.getGender());</p><p> System.out.println(nicDetails.getAge());</p><p> System.out.println(nicDetails.getFullAge());</p><p> }</p><p></p><p> private void setDetails(String nic) {</p><p> int year, days;</p><p> if (nic.length() == 10) { //OLD NIC-----------------------------------</p><p> year = Integer.parseInt("19" + nic.substring(0, 2));</p><p> days = Integer.parseInt(nic.substring(2, 5));</p><p> } else { //NEW NIC-----------------------------------</p><p> year = Integer.parseInt(nic.substring(0, 4));</p><p> days = Integer.parseInt(nic.substring(4, 7));</p><p> }</p><p> if (days > 500) {</p><p> setGender("Female");</p><p> days -= 500;</p><p> } else {</p><p> setGender("Male");</p><p> }</p><p></p><p> LocalDate date = LocalDate.ofYearDay(year, days);</p><p> if (!date.isLeapYear() && days > 60) {</p><p> date = date.plusDays(-1);</p><p> }</p><p> setBirthDay(date.toString());</p><p></p><p> //AGE-------------------------------------------------------------------</p><p> int oldYear = (int) ChronoUnit.YEARS.between(date, LocalDate.now());</p><p> setAge(oldYear);</p><p></p><p> Period elapsed = Period.between(date, LocalDate.now());</p><p></p><p> String text = oldYear + " years " + elapsed.getMonths() + " month(s) " + elapsed.getDays() + " day(s)";</p><p> setFullAge(text);</p><p></p><p> }</p><p></p><p> /**</p><p> * @param birthDay the birthDay to set</p><p> */</p><p> private void setBirthDay(String birthDay) {</p><p> this.birthDay = birthDay;</p><p> }</p><p></p><p> /**</p><p> * @param gender the gender to set</p><p> */</p><p> private void setGender(String gender) {</p><p> this.gender = gender;</p><p> }</p><p></p><p> /**</p><p> * @param fullAge the fullAge to set</p><p> */</p><p> private void setFullAge(String fullAge) {</p><p> this.fullAge = fullAge;</p><p> }</p><p></p><p> /**</p><p> * @param age the age to set</p><p> */</p><p> private void setAge(int age) {</p><p> this.age = age;</p><p> }</p><p>}</p><p>[/CODE]<span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span><strong></strong></p><p><strong><a href="https://en.wikipedia.org/wiki/National_identity_card_%28Sri_Lanka%29" target="_blank">https://en.wikipedia.org/wiki/National_identity_card_(Sri_Lanka)</a></strong></p><p><strong></strong></p></blockquote><p></p>
[QUOTE="MihiCherub, post: 19897833, member: 238676"] [B]NEW NIC ALGORITHM JAVA 8 [/B][SIZE=3]අලුත් NIC එකට පොඩි කෝඩ් කෑල්ල්ක් ලිව්ව. උබලට ඕනෙ විදියට වෙනස් කරගෙන පොඩ්ඩක් ටෙස්ට් කොරල බලල කියපල්ල හරිද කියල. උබලට ඕනෙ ප්රොජෙක්ට් වලින් ගෙඩිය පිටින්ම උස්සල පාවිච්චි කරපල්ල. :rofl: JAVA 8 එක්ක මහලොකු වෙලාවක් යන්නෙ නෑ. :D [/SIZE][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; } } [/CODE][SIZE=3] [/SIZE][B] [URL]https://en.wikipedia.org/wiki/National_identity_card_%28Sri_Lanka%29[/URL] [/B] [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom