Two Laptop Bag
The moose likes JSP and the fly likes Date and month by by default Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Date and month by by default" Watch "Date and month by by default" New topic

Date and month by by default

sandeep balyan
Ranch Hand

Joined: Jul 25, 2001
Posts: 134
Friends ..
Iam having JSP form s and Iam having a field which contains That this is for this Month means January or feb ..
I want to take this date using system date so that user should not fill wrong one ...It can come by default..that i know Select sysdate from dual..but the format I want is for monthly ..
So pls tell me the way possible..Iam also trying ..that is something related to SQL decoding ..I guess..
bye and take care

Want to do something great will do one day

Joined: Jan 04, 2002
Posts: 2
There are so many ways you can do that.

1) <%
Calendar cal = new GregorianCalendar();
cal.setTime( new java.util.Date() );
int curMon = 1+cal.get(Calendar.MONTH);
/* it will give the value from 1 to 12 and then in the text field you can assign this val as default
2) if u r happy to use sql query then use
select to_char(sysdate,'mm') from dual; This will give values like '01' to '12'. But I will recommend to use the first option.
I agree. Here's the link:
subject: Date and month by by default
It's not a secret anymore!