sir i have to make the program which get date of birth and give me result in term of how many year,months,days,hours,minutes and second old user is...

i need the help...

Recommended Answers

All 10 Replies

i need the help

Please show what you have so far and ask questions about your problems.

Go through the Java API . Look for Date class or Calender..

Do you have try anything? If so , then post.

i'll give a hint.You can use the system date to compare.Get the user date and reduce it from system date.........:):)

import java.util.Scanner;
import java.util.*;
import java.io.*;
class AgeCalculationn
public static void main(String args[])

Scanner var1=new Scanner(System.in);

Scanner var2=new Scanner(System.in);
Scanner var3=new Scanner(System.in);
Calendar cd=Calendar.getInstance();

int year,month1,day, month2;
int AgeYear,AgeMonth,Ageday;

System.out.println("Enter year of birth");

System.out.println("Enter month of birth");

System.out.println("Enter day of birth");



AgeMonth=cd.get(Calendar.MONTH) + month2;


System.out.println("Your Age is");

System.out.println("Years ="+AgeYear);

System.out.println("Month ="+AgeMonth);

System.out.println("Days ="+Ageday);


i have write this program in this way...but i know there is no any good logic..so please help. me...

Please explain what your problem is.
Execute the program, copy the console and paste it here and explain what you want the output to look like.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.

i want this output

Enter ur age...
for example 23/11/1986

then show output

you are
24 years
9 months
20 days
year old

What methods in the Calendar class have you tried to use so far?
First you need to parse the date into a class object.
Then there are methods to work with the date that is in the object.

im learning basic in java....so i m not so aware with classes..
plz help to make program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.