Java Code for Age

This java programming code is used to find the age . You can select the whole java code by clicking the select option and can use it. When you click text, the code will be changed to text format. This java program code will be opened in a new pop up window once you click pop-up from the right corner. You can just copy, paste this java code and use it to find the age .

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Age
{
   public static void main(String []args)
     {
        int daysInMon[] = {31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31};  //Days in month
        int days, month, year;
        char[] dob = new char[110];
        days=12;
        month=8;
        year=1992;
        System.out.println("Date of Birth: "+days+ "/" +month+ "/" +year);
         Date d = new Date();
        System.out.println("Current Date: " +d.getDate()+ "/" +(d.getMonth()+1)+ "/" +(d.getYear()+1900));
                   
        days = daysInMon[month - 1] - days + 1;
            
        /*Calculating the num of year, month and date*/
        days = days + d.getDate();
        month = (12 - month) + d.getMonth();
        year = (d.getYear() + 1900) - year - 1;
                
        if (month >= 12)
        {
        year = year + 1;
        month = month - 12;
        }
        
        /*Result portion*/
        
        System.out.println("Age:" +year+ "years" +month+ "months" +days+ "days");
     }
}
Other Programming Codes
Online Calculator : Age Calculator
Click on the select code link to copy and paste this free java program code for age calculator.

english Calculators and Converters


Sitemap