Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date and month by by default

 
sandeep balyan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
sandeep
 
Nikhil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
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.
Cheers,
Nikhil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic