cancel
Showing results for 
Search instead for 
Did you mean: 

Strange Date problem in Web Dynpro

Former Member
0 Kudos

Hi

I'm facing a strange problem. I have an input field and have associated it to an attribute of type 'date'. when I click on the date picker ane choose the date, say, for example, if I choose 12/29/2005, it is correctly displayed as <b>12/29/2005</b> in the input field.

But when I print the value using wdcontext.currentcontextelement().getDate();,

the date is displayed as <b>12/28/2005.</b>

What could be wrong?? Please help.

Jack

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I remember a bug with time zones in earlier Web Dynpro versions. If you are using a more recent version (say >= SP9) and this bug still occurs, please open an OSS message.

Armin

Former Member
0 Kudos

Hello Jack,

Check your printer settings for Date. Also write the code

wdComponentAPI.getMessageManager().raiseException
(wdcontext.currentcontextelement().getDate());

when the page pops up before printing.

Please reward appropriate points.

Bala

Message was edited by: Bala Krishnan

Former Member
0 Kudos

hi bala

sorry...when i meant printing the date, i actually meant displaying the date in a confirmation dialog.

former_member185029
Active Contributor
0 Kudos

Hi Jack,

the problem is, may you are spliting the date and then displaying.

Because if you display

wdContext.currentContextElement().getDate();

It returns a date in format yyyy-mm-dd (java.sql.Date format) then you need to format the date to make it display as per your format.

Now if you see the function getMonth() for java.sql.Date, it returns month-1 for the month (i.e. 0 for jan 1 for feb etc.).

Also it returns year=current year -1900, so for 2006 you will find value getYear()=106.

Check the values accordingly and then format the date for display.

Hope that will work for you.

Ashutosh

Former Member
0 Kudos

Hi

Armin: I don't think I'm using SP9 or >. Im using 2.0.9. Does this include Sp9?

If not, where can i download SP9? Is it free?

Ashutosh:

Im having no problem with the year or month...Its only the day thats giving me a problem.

Moreover, when I use java.sql.date or java.util.date on my context attribute type, its not letting me map it to the input field.

How do I solve this problem??

jack

Former Member
0 Kudos

2.0.9 = SP9

Armin

Former Member
0 Kudos

Jack,

Try converting ur date into String format and then try printing it,this may give u the correct result.

<b>Date mydate = wdContext.currentContextElement().getDate();

String dat = mydate.toString();</b>

Now normally set this value to the textview and c whether u r able to get the same date as picked from the datepicker.

<b>wdContext.currentContextElement().setResult(dat);</b>

Note : Result att should be of the type string.

This should solve ur problem.

Regards,

Nagarajan.

former_member185029
Active Contributor
0 Kudos

Hi Jack,

may be following code will work.

DateFormat format=DateFormat.getInstance();
format.format(wdContext.currentContextElement().getDate());

Please tell me what is the output of this code.

Ashutosh

Former Member
0 Kudos

Thanks Armin. Guess I need to raise an OSS.

Former Member
0 Kudos

Hi Nagarajan

converting it to string did not work. it still showed me the previous day.

and i need to have the field as a Date so I can use date picker.

jack

Former Member
0 Kudos

Hi ashutosh

The output was : 1/4/06 6:30 PM when i selected the date as 1/5/2006.

Im working on another work around using milliseconds and converting it to my timezone.

once i get it to work, I'll post it here so it'll be useful.

thanks

jack