cancel
Showing results for 
Search instead for 
Did you mean: 

How to display current system Date in the Date Input field ?

Former Member
0 Kudos

Hi,

I am having a Date Input field( binded to Data type). On load, i would like to display the current system date filled in that input field.

How do i achieve this ?

Reg/Venkat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Ignore my previous post. Better you have to use the following code. Create one attribute type is Date. Then bind into Input filed. Then inside DOint() use the following code.

java.util.Date tempDate = Calendar.getInstance().getTime();

Date sqlDate = new Date(tempDate.getTime());

wdContext.currentContextElement().setDateva(sqlDate);

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

Hi,

Thanks to all for valuable comment on my question.

Reg/Venkat

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Venkatesan,

In your view in your init() method add the following code:

wdContext.currentContextElement().setOrderDate(new Date(System.currentTimeMillis()));

this is if your Date-attribute is in the root of the context.

else you have to set the date in the node where the date-attribute is present with:

IYOURNODEElement node = wdContext.createYOURNODEElement();

node.setOrderDate(new Date(System.currentTimeMillis()));

regards,

Björn

Former Member
0 Kudos

Hi

Assuming that you context attribute assigned to Date inputfield is Date.

Use following code:

Date dt = new Date(System.currentTimeMillis());

wdContext.currentContextElement().setDate(dt);

This will set the date to current date.

Regards,

Ajay

Former Member
0 Kudos

Hi,

In the wdDoInit() method, use this code:

Let's assume that you have a context attribute CurrDate of type date and it is bound to your inputfield.


long currentTime = System.currentTimeMillis();
wdContext.currentContextElement().setCurrDate(new java.sql.Date(currentTime - (currentTime % 86400000)));

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

java.util.Date tempDate = Calendar.getInstance().getTime();

Date sqlDate = new Date(tempDate.getTime());

Calendar cal = Calendar.getInstance(TimeZone.getDefault());

String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);

sdf.setTimeZone(TimeZone.getDefault());

String xx=sdf.format(cal.getTime());

then convert into Date and bind into Variable.

Kind Regards,

S.Saravanan.