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
Date and Calender help
vuthlarhi donald
Ranch Hand
Posts: 76
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public static String getExpiaryDate() { { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, 30); // add 30 days int days = calendar.get(Calendar.DAY_OF_MONTH); // get the days plus 30 days....but I am not getting the new date with 30 days added if (days != 1) { calendar.add(Calendar.MONTH, 0); calendar.set(Calendar.DAY_OF_MONTH, 1); } Date date = calendar.getTime(); DateFormat format = new SimpleDateFormat("dd/MM/yyyy"); return format.format(date); } }
Piyush Porwal
Ranch Hand
Posts: 30
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I suppose
you should
use calendar.add(Calendar.DAY_OF_YEAR, 30 ),
as Calendar.DAY_OF_MONTH must be getting overflow from it's max value.
-Piyush Porwal (Junk box)
I found a beautiful pie. And a 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
How to get tomorrow's date?
Date and Calendar
Date - finding tomorrow
Is java Date/Calendar a bug?
getting a Date that is 30 days ago from today
More...