aspose file tools*
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
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: 60063
    
  65

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
 
Similar Threads
Query problem with MySQL 5
java Date
Question about Calendar
Portal Server v6.0 Initialization Problem
I have some problems