Date addition

W

web02

I have a Date field named birthDate. How would I add 19 years to his guys
birthday?

Thanx,
Bill
 
W

web02

I'm new to Java, got a deadline pushing me and I haven't used a Calendar
object. An example, please.

Thanx,
Bill
 
M

Matt Humphrey

web02 said:
I'm new to Java, got a deadline pushing me and I haven't used a Calendar
object. An example, please.

Please don't top-post--put your comments after other's comments. A basic
example is below, but expect to read the Javadocs if you plan on getting
ahead.

And yes, we all have deadlines.

Calendar c = GregorianCalendar.getInstance();
c.setTime (birthDate);
c.add (Calendar.YEAR, 19);
Date result = c.getTime()

Matt Humphrey http://www.iviz.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top