Jeetandra Mahtani wrote:
> Hello,
> I have a hidden Date field in a form. Before the
> servlet can add a record to the database, I need to
> set this date field to the current date but I can't
> seem to get the year in the format of yyyy. Also, I
> need the Date and the month to always be of two
> characters. Like today it is set as 99526 but I need
> it as 19990526.
> I've been using
> Date c1crdt = new Date();
> String curdate =
> c1crdt.getYear()+c1crdt.getMonth()+c1crdt.getYear();
> Any suggestions/ideas?
> Thanks,
> J
For the year, just add 1900 to the value returned by getYear(). This doesn't
solve the month and day problems though. Your best bet is to look at the
java.text.SimpleDateFormat class, which lets you build format strings in
pretty much any format you like.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html