Home Tutorialhelp Allcomments Java Example Java Util Agecalculation

 
 

Comments

 
User Comments for the tutorial:

Determining the actual age from date of birth in Java



Advertisement
Comments

excellent
It really solved my problem of getting the right age of a person based on his date-of-birth. thanks a lot. Keep it up.... -Mone 

Possible error
I think the line: monthsDiff = 12 + to.get(Calendar.MONTH) - from.get(Calendar.MONTH); Should be: monthsDiff = 11 + to.get(Calendar.MONTH) - from.get(Calendar.MONTH); 

Another solution for age
Calendar today = GregorianCalendar.getInstance(); Calendar dob = GregorianCalendar.getInstance(); dob.setTime(dateOfBirth); int age=0; while(dob.after(today)==false){ dob.add(Calendar.YEAR, 1 

calendar
Thanks for the code. I see I got a negative day number but I worked around it. Tried to figure out how many seconds I was alive but didn't know how to use the time method with it 

Related Tutorial and Articles
Java-Tutorials

Lang and Util Base Libraries
Lang and Util Base Libraries The Base libraries provides us the fundamental features and functionality of the Java platform. Lang and Util Packages Lang and Util package provides the fundamental classes and Object of primitive type 

Java Beginners

util packages in java
util packages in java  write a java program to display present date and after 25days what will be the date?   import java.util.*; import java.text.*; class FindDate{ public static void main(String[] args 

Java-Tutorials

Java Util Examples List
examples that demonstrate the syntax and example code of java util package... Java Util Examples List - Util Tutorials       The util package or java provides many 

Java-Tutorials

Java util package Examples
 

Java-Tutorials

Java Util Package - Utility Package of Java
Java Util Package - Utility Package of Java       Java Utility package is one of the most commonly used packages in the java program. The Utility Package of Java consist 

Java Beginners

Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.   import java.io.File; import... this code works wonderful, its another example from a different website. The only 

Java Beginners

java util date - Time Zone throwing illegal argument exception
java util date - Time Zone throwing illegal argument exception  Sample Code String timestamp1 = "Wed Mar 02 00:00:54 PST 2011"; Date d = new Date...()); The date object is not getting created for IST time zone. Java 

Java Beginners

util
 

Core Java

Java util date
Java util date         The class Date in "java.util" package represents... to string and string to date. Read  more at: http:/www.roseindia.net/java/java 

Java-Tutorials

Associate a value with an object
with an object in Java util. Here, you will know how to associate the value... of the several extentions to the java programming language i.e. the "...;} } Download this example 

Advertisements Advertisements
 

 

 

DMCA.com