cancel
Showing results for 
Search instead for 
Did you mean: 

how to link date to the day of the date?

Former Member
0 Kudos

hi

I have a text box with date on it ,i have another text box ,i want that when user select a date on my previous text box ,the week of the day of that particular date selected is displayed.

For e.g date selected is 08/09/2006in one text box and automatically on other text box Friday comes.

Regards

Nidhideep

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,


Date datefromInputField = ....;
SimpleDateFormat df = new SimpleDateFormat("EEEE");
String s = df.format(datefromInputField );
// s is now equal to the day of week

Regards

Sebastian

Former Member
0 Kudos

hi

Sebastain ,I have made an action selectday bind it to the UI element order date of type date:

onselectday(){

Date orderdate = wdContext.currentcontextelement.order_date();

SimpleDateFormat df = new SimpleDateFormat("EEEE");

String s = df.format(orderdate);

//now setting my text box which will show day

wdContext.currentContextelement.setBox(s);

but the desired result is not coming

Plz help me

Regards

Nidhideep

Former Member
0 Kudos

Hi,

The statement, Date orderdate = wdContext.currentcontextelement.order_date(); is it typed by you? it will give error.

Date orderdate = wdContext.currentContextElement().getOrder_date();

and instead of wdContext.currentContextelement.setBox(s);

use wdContext.currentContextElement().setBox(s);

Former Member
0 Kudos

Hi

This Code Working Fine

Date date = wdContext.currentContextElement().getTestDate();

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("EEEEEEEE");

String wd=sdf.format(date);

wdComponentAPI.getMessageManager().reportSuccess(wd);

wdContext.currentContextElement().setBox(wd);

Check that the event is call the function

Kind Regards

Mukesh

Former Member
0 Kudos

hi

thanx to all i have solved my problem

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

There is no action tiggered when you click the calendar of the Date input field.

but you can write action for the textbox(ie., press ENTER Key).

try this code,

Date dateNow=wdContext.currentContextElement().get<DateofText1>();

int dayNo=dateNow.getDay(); //returns the day of the week

switch(dayNo)

{

case 0: wdcontext.currentContextElement().set<DateofText2("Monday");

break;

case 1: wdcontext.currentContextElement().set<DateofText2("Tuesday");

break;

.

.

.

up to case 6:

}

regards

karthik

Former Member
0 Kudos

Hi,

if this is not sufficient for you use a DateNavigator UIElement which support binding an actionhandler on the onDaySelect action. For the fomatting issue use the SimpleDateFormat.

Regards

Sebastian

Former Member
0 Kudos

Hi Nidhideep

Use SimpleDateFormat for this.

SimpleDateFormat sdf = new SimpleDateFormat("EEEEEE");

String weekday = sdf.format(<pass the date>);

Use string attribute Weekday and attach with other textbox.

wdContext.currentContextElement().setWeekday(weekday);

Do this on the action of user selecting the date.

I hope it helps

Thanks

Srikant