cancel
Showing results for 
Search instead for 
Did you mean: 

Set date to context

Former Member
0 Kudos

Hi,

I am trying to fetch the date from SQL table which is in the format of 22/12/2008. How can i convert that format to Web dynpro exceptble Date.

I want to set that value to one of the context which has its type as Date.

Like this.

Date dateU=rsDate.getDate(1);
wdContext.currentPersonalDataElement().setDate(dateU);

Can any one help me.

Regards,

H.V.Swathi

Edited by: H.V Swathi on Jan 9, 2009 8:18 AM

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Swathi,

As far as I see, I do not see any problem in your code. Just try with java.sql.Date as follows:

java.sql.Date dateU=rsDate.getDate(1);
wdContext.currentPersonalDataElement().setDate(dateU);

Best Regards,

Gopal

Former Member
0 Kudos

Hi,

Thanks Gopal. But I am finding this error for the code what u gave.

The method setDate(Date) is undefined for the type IPrivateEntryView.IPersonalDataElement EntryView.java

Regards,

H.V.Swathi

Former Member
0 Kudos

Hi Swathi,

Is date attribute under node PersonalData in view PrivateEntryView is of date datatype? Can you please check that?

Best Regards,

Gopal

Former Member
0 Kudos

Hi,

You can have your context attribute of type java.util.date or java.sql and where you can set. If you want to change the format have a work around as below using simple date format.

try

{

long l = System.currentTimeMillis();

java.sql.Date dt = new java.sql.Date(l);

wdComponentAPI.getMessageManager().reportSuccess("Date: " + dt);

SimpleDateFormat g_objDateFormat = new SimpleDateFormat("MMMM dd, yyyy");

wdContext.currentContextElement().setAbc(g_objDateFormat.format(dt));

}

catch (NullPointerException e)

{

wdComponentAPI.getMessageManager().reportException(e.toString(), true);

}

//@@end

}

Regards

Raghu

Former Member
0 Kudos

Hi,

Try this code,

try

{

long l = System.currentTimeMillis();

java.sql.Date dt = new java.sql.Date(l);

wdComponentAPI.getMessageManager().reportSuccess("Date: " + dt);

SimpleDateFormat g_objDateFormat = new SimpleDateFormat("MMMM dd, yyyy");

wdContext.currentContextElement().setAbc(g_objDateFormat.format(dt));

}

catch (NullPointerException e)

{

wdComponentAPI.getMessageManager().reportException(e.toString(), true);

}

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Hi Swathi,

->Create a Dictionary Simple Type called myDate in the Local Dictionary of your Web Dynpro project.

->In the Definition Tab, select its Built-In Type as timestamp.

->Now switch to the Representation tab and give the required DateFormat (Ex. dd/mm/yyyy) in the Format field.

->Re-create your context attribute Date of this type created, i.e myDate.

->Use this to set the value of your Context attribute,



wdContext.currentPersonalDataElement().setDate(rs.getDate(1).toString());

Regards

Kishan

Edited by: kishan chandranna on Jan 9, 2009 9:49 AM

Former Member
0 Kudos

hi swathi,

if you are getting sql date from database then

1. create a context of sql date type

2. and the set Date directly which is coming from database (date must be in form of sql date).

Regards

Narendra

Former Member
0 Kudos

Hi,

refer this thread,

Regards,

ramesh

former_member201361
Active Contributor
0 Kudos

Hi Swathi,

try this code , it may help u

Date dateU=rsDate.getDate(1);

java.util.Date jDate =

new java.util.Date(dateU.getTime());

wdContext.currentDateElement.setDate(jDate);

Thansk and regards