on 01-09-2009 7:18 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.