This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Need help writting an expiration date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help writting an expiration date" Watch "Need help writting an expiration date" New topic
Author

Need help writting an expiration date

bob morkos
Ranch Hand

Joined: Oct 06, 2003
Posts: 56
Hi,
I need to write a one year expiration date function. Any sample code would be appreciated, I don't know either to use the date calendar or the SimpleDateFormat? Thanks in advance for any help.
Chris De Vries
Ranch Hand

Joined: Dec 05, 2002
Posts: 65
You can do something like:

Which will cause the software to expire on January 1, 2004.
Chris
bob morkos
Ranch Hand

Joined: Oct 06, 2003
Posts: 56
What does these parameters mean for:
expires.set(2004,0,1,0,0,0);
The only one that I can guess is 2004. I want to set the expire date one year from the current date.

Originally posted by Chris De Vries:
You can do something like:

Which will cause the software to expire on January 1, 2004.
Chris
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
to get a date 1 year from now use the following:
Chris De Vries
Ranch Hand

Joined: Dec 05, 2002
Posts: 65
The Java API docs are a good place to go if you want to find out more about a method call.
Calendar.set(int,int,int,int,int,int) is documented there. The arguments are year, month (starting with 0), date, hour, minute, and second.
[ October 06, 2003: Message edited by: Chris De Vries ]
bob morkos
Ranch Hand

Joined: Oct 06, 2003
Posts: 56
The date field do they mean the day of the month. Thanks for your reply. But, I'm using jdk1.3.1 and not jdk1.4, can I still use the set calendar function.
Originally posted by Chris De Vries:
The Java API docs are a good place to go if you want to find out more about a method call.
Calendar.set(int,int,int,int,int,int) is documented there. The arguments are year, month (starting with 0), date, hour, minute, and second.
[ October 06, 2003: Message edited by: Chris De Vries ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
But, I'm using jdk1.3.1 and not jdk1.4
Use the API at http://java.sun.com/j2se/1.3/docs/api/index.html
This can also be found from http://java.sun.com/docs


"I'm not back." - Bill Harding, Twister
 
Don't get me started about those stupid light bulbs.
 
subject: Need help writting an expiration date