cancel
Showing results for 
Search instead for 
Did you mean: 

setting today's date

Former Member
0 Kudos

Hi,

can anybody tell how to set current date in an input field by using java.sql.Date.

I am binding this input field to a value attibute of type 'date' so that the user can edit the date also.

Accepted Solutions (1)

Accepted Solutions (1)

PradeepBondla
Active Contributor
0 Kudos

Hi,

use this in wdDoInit...

wdContext.currentContextElement().set<yourDateAttributeNameWhichmappedtoinputfield>(new java.sql.Date( System.currentTimeMillis() )
    );

else check the Velary's code in

PradeeP

Former Member
0 Kudos

Thanx Pradeep,

The issue is resolved.

Can you tell me how to set 10days before the current date??

Former Member
0 Kudos

Hi,

use the following to set 10 days before the current date??


	Date date = new Date(Calendar.getInstance().getTimeInMillis());
	
	Calendar calD = Calendar.getInstance();	
	
	calD.setTime(date);
	
	calD.add(Calendar.DATE,-10);
	
	date.setTime(calD.getTimeInMillis());

now "date" will holds the required Date .

Regards,

ramesh

Edited by: Ramesh Babu V on Dec 23, 2008 7:54 PM

Former Member
0 Kudos

Hi,

Thanks the issue is resolved.The format is coming in YYYY/MM/DD. I want it in DD/MM/YYYY.

Any hints for that?

Former Member
0 Kudos

Hi,

use below code ,

SimpleDateFormat formatDate = new SimpleDateFormat ("dd/mm/yyyy");

String stringDate = formatDate .format (date);

Regards,

ramesh

Answers (0)