aspose file tools*
The moose likes JDBC and the fly likes How to get date of next anniversary ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get date of next anniversary ?" Watch "How to get date of next anniversary ?" New topic
Author

How to get date of next anniversary ?

Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
Hi, all
is there any easy way( no complex conversion) to get a new Date of the next anniversary of a given Date ?
e.g. from 12/13/2001 => 12/13/2002
Thanks.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Sylvia Wang:
Hi, all
is there any easy way( no complex conversion) to get a new Date of the next anniversary of a given Date ?
e.g. from 12/13/2001 => 12/13/2002
Thanks.


Jamie
Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
it's great !
Thank you !
Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
Sorry, found a small problem,
the Date type returned by getTime() is java.util.Date
tried to downcast to java.sql.Date by
java.sql.Date = (java.sql.Date)util_date;
but doesn't work. why ?
Thxs.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Try this...
java.util.Date today = new java.util.Date();
java.sql.Date td = new java.sql.Date(today.getTime());

------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

here is a neat and quick way to convert it in your code:

the first getTime() returns a Date object, the second getTime() is on the returned Date object which returns a long...which is used in the constructor of java.sql.Date.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get date of next anniversary ?