on 05-02-2008 7:31 AM
hi
i am trying to initialize an input field of type date(ie bound to a context of type date)
wdContext.currentContextElement().setVa_fromdate(xxxxx);
what do i write in place of xxxxx
Plz help
Hi Himanshu,
You can use the following code:
//You can get current date
Date currDate = new Date(System.currentTimeMillis());
//You can set your context like this:
wdContext.currentContextElement().set<attribname>(currDate);
Thanks n Regards,
Jhansi Miryala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Since you have taken a context attribute of date type,so this attribute accepts a value of date format only.so cant give any data to this context attribute.
To set this attribute with current date, you can use following code:
java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
wdContext.currentContextElement().set<attributename>(date);
For your information,this will not set the attribute with system date instead it will set the date of sql server.
if you want to set this attribute with system date,then use below mentioned code:
Date sysDate = new Date(System.currentTimeMillis());
wdContext.currentContextElement().set<attributename>(sysDate);
regards,
amit bagati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi himangshu,
Use this code
//Date of type java.sql.Date
//for setting the current date
java.sql.Date date;
wdContext.currentContextElement().setDate( date = new Date( System.currentTimeMillis()));
//sets the custom date
Calendar calendar = Calendar.getInstance();
calendar.set( 2008, 05, 02);
wdContext.currentContextElement().setDate( new Date( calendar.getTimeInMillis()));
Regards
Vinod V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if the attribute type is date you need to set java.sql.Date instance in the set method
//for current system date:
Date current = new Date(System.currentTimeMillis());
//for a date of your choice:
Calendar cal = Calendar.getInstance();
cal.set(1998,10,01);
Date old = new Date (cal.getTimeInMillis());
wdContext.currentContextElement().setVa_fromdate(xxxxx);
// you can set current or old as parameter
nikhiL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Himanshu,
Never initialize you date with someother date.
Best way is to initialize it with todays date..i.e.current date.
if your date type is sql.date then
java.sql.Date l_sqlD = new java.sql.Date(new java.util.Date().getTime());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.