This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Facing problems in subtracting two date. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Facing problems in subtracting two date." Watch "Facing problems in subtracting two date." New topic
Author

Facing problems in subtracting two date.

lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi every body i am facing problem while subtracting current date with given date actually the requirement is that i have to get date of birth as input and subtract it to current date to get total year.can any body help me to solve this problem.

Regards,
Lokesh Kumar Pattajoshi
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Check out java.util.Calendar, especially its get method in combination with Calendar.YEAR and Calendar.DAY_OF_YEAR. In short:
- calculate the difference in years
- if the current date is before the birthday, subtract one (hasn't had his birthday yet)


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Thank you very much Rob my broblems is solved now.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Facing problems in subtracting two date.
 
Similar Threads
Ajax + mozilla
how to delete files datewise..
date problem
Getting Previous Date
how to get 3 days less than current date in java