on 04-07-2010 8:18 AM
Hi Friends,
In Portal calender side that Date format show like (mm/dd/yyyy) like that i need display the date format in portal calender(dd/mm/yyyy) like this. So i have to done some code here
Ymm_Sc_Bapieindt delvDateRange = new Ymm_Sc_Bapieindt();
wdContext.nodeDaterange().bind(delvDateRange);
SimpleDateFormat sdfDate = new SimpleDateFormat("DD/MM/YYYY");
String datestr = sdfDate.format(new java.util.Date());
delvDateRange.setFrom_Date(datestr);
delvDateRange.setTo_Date(datestr);
input.addDaterange(delvDateRange);
i am getting Error here.
delvDateRange.setFrom_Date(datestr);
delvDateRange.setTo_Date(datestr);
That error is This method setFrom_Date/setTo_Date(Date) in the type Ymm_Sc_Bapieindt is not applicable for the arguments (String)
I m getting this error
How to slove this
Regards
Vijay
Hi Vijay,
You can just parse the date into which ever format you like.
Date startDate = null;
String strStartDate = null;
strStartDate = wdContext.currentNode_Element().getValueAttriute();
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
try {
startDate = df.parse(strStartDate);
}
catch (ParseException e) {
wdComponentAPI.getMessageManager().reportException("Error in Formatting the Date",false);
}
Hope this helps you.
Regards,
p188071.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I m doing like this
SimpleDateFormat sdfDate = new SimpleDateFormat("DD/MM/YYYY");
String datestr = sdfDate.format(new java.util.Date());
delvDateRange.setFrom_Date(datestr);
delvDateRange.setTo_Date(datestr);
input.addDaterange(delvDateRange);
here datestr shows:datestr:::08/04/2010 like this i need to display in calender this format.
next what can i dooo.. can u tell exact codeing
Regards
Vijay
Hi Vijay,
Please try this :-
SimpleDateFormat sdfDate = new SimpleDateFormat("DD/MM/YYYY");
String datestr = sdfDate.format(<Format the date as per sdfDate format - DD/MM/YYYY like wdContext.currentContextElement().get<ATTRIBUTE Name>() WHICH you want to format>);
Date n_date = new Date(datestr);
delvDateRange.setFrom_Date(n_date); ->> if From_Date only accept Data parameter.
Refer to http://techtracer.com/2007/03/28/convert-date-to-string-and-string-to-date-in-java/
Hope it helps
Regards
Arun
Hi Vijay
This is the basic concept in Java coding which do not require any special wd concepts or anything. Only requirement is -- First you must know exactly what you need to achieve & what it will take to achieve.
Here is the example -
public class StringToDate
{
public static void main(String[] args)
{
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
try
{
Date today = df.parse("08/04/2010");
System.out.println("Today = " + df.format(today));
} catch (ParseException e)
{
e.printStackTrace();
}
}
}
And here is the result of our code:
Today = 08/04/2010
Let me explain you as I guess you might not know what this code is actually doing.
The example starts by creating an instance of SimpleDateFormat with "dd/MM/yyyy" format which mean that the date string is formatted in day-month-year sequence.
Finally using the parse(String source) method we can get the Date instance. Because parse method can throw java.text.ParseException exception if the supplied date is not in a valid format; we need to catch it.
Following are the imports you need to make
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
I really hope this will let you understand few more concepts.
Best Regards
Chander Kararia
If you got the solution, please mark the thread as answered.
Hi Vijay ,
1) Instead of Java Coding , Change the User Language Parameters in User administration to English UK , Date will be displayed in dd.mm.yyyy format.
2)Use can Also change the language settings for a system , Goto Control Panel->Regional and Language Options , here Select English (United Kingdom )From Drop down , but this will work only for that desktop.
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,
I understand, you are trying pass parameter String (SimpleDateFormat will return String) instead of type Date.
Try to pass the date value to the parameters and check it again.
Regards,
Saravanan K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.