cancel
Showing results for 
Search instead for 
Did you mean: 

Date field should be different

Former Member
0 Kudos

Hi

Iam creating an application in web dynpro.In that labels "From Date" and "To Date" labels are present.

In that i created Context of type "Date".

I written code like this.

Date date=new Date();

java.sql.Date today=new java.sql.Date(date.getTime());

wdContext.currentTimelogElement().setFromDate(today);

wdContext.currentTimelogElement().setToDate(today);

While writing like this,its showing todayDate as "From Date " and "To Date ".

I want both the Dates should be different.

Suppose "From Date-06/02/2009" "To Date---10/02/2009" or

From Date-01/02/2009" "To Date---06/02/2009"

For that what are the modifications i have to do in the Code.

Regards

Sushma

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

tx

chander_kararia4
Contributor
0 Kudos

Hi Sushma,

your code

Date date=new Date();

java.sql.Date today=new java.sql.Date(date.getTime());

wdContext.currentTimelogElement().setFromDate(today);

wdContext.currentTimelogElement().setToDate(today);

new code

1. No need to use getTime as you want to display the date.

2. To hard code the dates

Date fromDate = new Date("10/25/2008"); // date in format : mm/dd/yyyy

Date toDate = new Date("01/05/2009"); // date in format : mm/dd/yyyy

Regards

Chander Kararia

Former Member
0 Kudos

Hi,

IF you want both the dates in different format create 2 contex variables and bind them to a simple type of type date with the format you want.

Bind these 2 context varibales to the fromDate and ToDate

Regards,

Padma N

Former Member
0 Kudos

Hi..

If you want the different dates, create two value attributes of the type date and bind it to the 2 input field FROM and TO... It will diplay the calender. so that u can select the different dates.

No need to write any coding..

If u want to display the current date in the FROM field you can use this coding..

java.util.Date ud = new java.util.Date();

java.sql.Date sd = new java.sql.Date(ud.getDate());

sd.setYear(ud.getYear());

sd.setDate(ud.getDate());

sd.setMonth(ud.getMonth());

wdThis.currentContextElement().setFromdate(sd);

Here Fromdate is the value attribute of the type date.

Regards,

Alamelu

Former Member
0 Kudos

Hi Sushma,

Create 2 Date instances for 'FromDate' & 'ToDate' with required values & set them.

Example:

java.sql.Date fromDate = new java.sql.Date(109, 1, 1); // This is 1st Feb, 2009

wdContext.currentTimelogElement().setFromDate(fromDate);

Similarly, java.sql.Date toDate = new java.sql.Date(109, 1, 6); // This is 6th Feb, 2009

wdContext.currentTimelogElement().setToDate(toDate);

For details, refer http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Date.html

Hope this answers your query.

Kind Regards,

Nitin

Edited by: Nitin Jain on Feb 6, 2009 6:41 AM

Former Member
0 Kudos

Hi,

You are setting the todays date for both the context fromdate and todate. You can set whatever dates you want like

wdcontext.curentcontext.setfromdate("Yourdate");

Hope this helps.

Regards,

Prasanthi

Former Member
0 Kudos

Hi

I have taken UI Element "Input Field ".In that i had takenit of type "Date".

So in the layout for inputfield the calendar will be displayed.

Iam hardcoding the Values.I written code like that which i posted.

MY question is the "From Date" and "To date" must be hardcoded with different dates.

Regards

Sushma