|
-
April 15th, 2010, 09:28 AM
#4
Re: Finding the time between two Dates
 Originally Posted by white feather
..................
System.out.println("You are: \nYears: " + (int) yearz + "\nMonths: "
+ totalMonths + "\nDays: " + (int) dayz + "\nHours: " + hours
+ "\nMinutes: " + minutes + "\nSeconds: " + seconds + " old");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis((long) d);
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
System.out.println(formatter.format(calendar.getTime()));
}
This is what i have so far. It calculates the year and month correctly but it has a little trouble with the day
Ex.
if the user enters Dec. 1, 1990 for their birth date the output should be
You are 19 years, 4 months, 12 days, 8 hours, 44 minutes, and 39 seconds old.
Thanks in advance
If you dont ;like 8 hours, 44 minutes, and 39 seconds old.
, dont print this information.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|