on 10-13-2008 6:08 AM
Hi ,
I have date value in one attribute it is coming from RFC.
If I will bind the value directly to the text view ,data is getting like 10/12/2008. But whenever I am taking this value and formatting into Simple date format as October 13th,2008,I am getting "NullPointer Exception".
Code is in init() of View :
//Format Draft_Date
Date l_CreDat = wdContext.currentCtx_vn_DataElement().getCredat();
wdComponentAPI.getMessageManager().reportSuccess("Date: " + l_CreDat);
g_objDateFormat = new SimpleDateFormat("MMMM dd, yyyy");
wdContext.currentContextElement().setCtx_va_Date(g_objDateFormat.format(l_CreDat));
}catch (NullPointerException e)
{
wdComponentAPI.getMessageManager().reportException(e.toString(), true);
}
Please help me.
Thanks
Risha
Hi Risha,
After setting the data into context attribute, bind the attribute with the context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
My problem is solved.
I am populating the nodes after that I have to set the date field in Component Controller. Next I converted date into Simple date format.Problem is solved.
Thanks for all.
Regards
Risha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Risha,
Use the following code to get your required functionality
l_CreDat.toLocaleString().substring(0, 12);
You will get the output in the form Oct 14, 2008 which you require.
Hope this will help.
Thanks & Regards
Sagar Ingalwar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Risha,
I had just tried your code, every thing is working fine for me, I think there might be some problem in getting the data or setting the date to Context Attribute. But your are confident on getting the date. So check the context attribute where you are setting.
I am just posing the code which i had tried. I tried with system date but it is off java.sql.date type.
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
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Before accessing the following line make sure that the wdContext.currentCtx_vn_DataElement() is not null
if(wdContext.currentCtx_vn_DataElement() != null)
{
Date l_CreDat = wdContext.currentCtx_vn_DataElement().getCredat();
wdComponentAPI.getMessageManager().reportSuccess("Date: " + l_CreDat);
g_objDateFormat = new SimpleDateFormat("MMMM dd, yyyy");
wdContext.currentContextElement().setCtx_va_Date(g_objDateFormat.format(l_CreDat));
}catch (NullPointerException e)
{
wdComponentAPI.getMessageManager().reportException(e.toString(), true);
}
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
once check the value of "g_objDateFormat.format(l_CreDat)".
Regards,
ramesh
Edited by: Ramesh Babu V on Oct 13, 2008 10:45 AM
Edited by: Ramesh Babu V on Oct 13, 2008 10:52 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
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.