This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Facing problems in subtracting two date.  RSS feed

 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Rob my broblems is solved now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!