on 09-22-2005 10:03 AM
Hi,
I have a view with an input field for date.
The input field is bound to a value attribute of type Date.
Initially, when the view is displayed, I want the field to be populated with current date in the format mm/dd/yyyy.
Can anyboby let me know how you can obtain the current date ( only mm/dd/yyyy ) and diplay it in the input field?
Thanks in advance,
Reena
in wdDoInit of view:
wdContext
.currentContextElement()
.set<DateAttributeName>
(
new java.sql.Date( System.currentTimeMillis() )
);
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
Thanks a ton for the help. I was able to solve the problem.
Special thanks to Valery !
Regards
Reena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reena,
you can get the full date in this format like :: 09/22/2005
String date = (new SimpleDateFormat("MM/dd/yyyy").format(new java.util.Date()));
So now set this value to ur context attribute.
create a value attribute in the context of type string(dt), bind this to the input field, and in the implementation part of Init method add this code.
wdContext.currentContextElement().setDt(date);
(be sure that yyyy and dd are small letters)..
All the best.
Regards,
Sirisha.R.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Reena,
Write following code to set current date value.
wdcontext.currentcontextelement().set<attribute>(new Date());
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
Thanks a lot. I have awarded full points
I have another question.
How do I get the date exactly 1 month prior to the current date? (In the same format mm/dd/yyyy)
Because I actually have two input fields.
"From Date" and "To Date".
I was able to populate the "To Date" field with ur help.
Now I need to populate the "From Date" field with the date exactly 1 month prior to the current date.
Thanks in advance.
Regards,
Reena
final long now = System.currentTimeMillis();
final java.sql.Date till = new java.sql.Date(now);
final Calendar c = Calendar.getInstance
(
WDResourceHandler
.getCurrentSessionLocale()
);
c.setTimeInMillis( now );
c.add( Calendar.MONTH, -1 );
final java.sql.Date from = new java.sql.Date( c.getTimeInMillis() );
Good luck!
Valery Silaev
EPAM Systems
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.