Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Beginning Java
how to add one year to today's date in java
Bhasker Reddy
Ranch Hand
Posts: 176
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How to add one year to Today's date in
java
. do you have any examples that does it.
I will appreciate if someone can help me
Bhasker Reddy
Jamie Robertson
Ranch Hand
Posts: 1879
I like...
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Calendar today_plus_year = Calendar.getInstance(); today_plus_year.add( Calendar.YEAR, 1 );
Jamie
[ August 28, 2002: Message edited by: Jamie Robertson ]
Neil Laurance
Ranch Hand
Posts: 183
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
One way to do this:
import java.util.Calendar; import java.util.Date; import java.text.Format; import java.text.SimpleDateFormat; public class AddYear { public static void main(String[] args) { Calendar date = Calendar.getInstance(); date.setTime(new Date()); Format f = new SimpleDateFormat("dd-MMMM-yyyy"); System.out.println(f.format(date.getTime())); date.add(Calendar.YEAR,1); System.out.println(f.format(date.getTime())); } }
Cheers, Neil :roll: :roll:
Neil Laurance
Ranch Hand
Posts: 183
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Darn, Jamie was quicker on the draw
Jamie Robertson
Ranch Hand
Posts: 1879
I like...
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Originally posted by Neil Laurance:
Darn, Jamie was quicker on the draw
cause I was too lazy to type out all that extra stuff you included!
Mike Curwen
Ranch Hand
Posts: 3695
I like...
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Moving from
Servlets
-> Java In General / Beginner
Onion rings are vegetable donuts. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
"Ruby Rulez" written over Moose?
how do I find date difference in months
calculate todays date minus last one year in java
How to store compile time data in Java
Why The LOGO and My name are upside down
More...