• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reg age cal

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

How to caluculate a age if date of birth is in this format 01/12/1875


Regards,
Vijay.
 
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, don't know what it is you are requesting?

Are you asking:

a) If i have a date in mm/dd/yyyy format how do i contvert that to a date so i can calculate age?, or

b) What is the algorithm given a date to determine one's age?, and if so what is the format of the age (years old, years and days, years and months and days, ...hours? minutes? seconds?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at SimpleDateFormat. You can use that to parse a String into a Date object.

If you build Date objects for current time and birth date, you can work out the time between them with pretty simple math. Look at the doc for Date ... do you see a method that returns a number we might do math on? See if you can compute age in days or years. Avoid months - they're all different sizes which makes them mostly meaningless.

These are pretty vague hints ... I hope you have fun digging out the details yourself.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"if date of birth is in this format 01/12/1875"

So, is that January 12th, or 1 December? Using 01/12 as an example for date/month or month/day isn't very informative in an international context. Try 01/31 or 31/12.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic