This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java API - to get next year Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java API - to get next year" Watch "Java API - to get next year" New topic
Author

Java API - to get next year

Shadab F Hashmi
Greenhorn

Joined: Feb 13, 2006
Posts: 9
Hi,

I have a requirement where i have a date like "2006-08-21 09:53:58.0", so i need to get the last date of the next year like "2007-12-31 09:53:58.0".

Does Java API provide any method where if i give the date like "2006-08-21 09:53:58.0" and output i get "2007-12-31 09:53:58.0".

Can anyone please mail me the code.

Thanks inadvance for all the help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63342
    
  70

Check out the java.util.Calendar class.
[ September 12, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Denysis Volpi
Greenhorn

Joined: Sep 13, 2006
Posts: 1
I think I would use a GregorianCalendar to construct a date:

GregorianCalendar(int year, int month, int date, int hour, int minute, int second) Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.

Then use the set() function of the Calendar class

set(int year, int month, int date)
Sets the values for the fields year, month, and date.

To set the new year, month and day values.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java API - to get next year
 
jQuery in Action, 3rd edition