on 09-06-2007 6:36 AM
Hi,
I am getting date from the frontend in mm-dd-yyyy format.But BAPI accepts date only in yyyymmdd format.How should I pass date to BAPI in required format. Can I use Date Object to pass date to BAPI and how?
Regards,
Samir
Hi samir,
Declare Date dateObject={pass your value here} Then while passing value to BAPI follow the code given below.
new Date(dateObject.getYear(),dateObject.getMonth(),dateObject.getDay());
regards
sukanta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Samir,
otherwise if you want to pass to the BAPI the date in Date Format (instead of String format as Venkatesh suggested) another way is this:
//dat is your string MMddyyyy
datDate = easyDateFormat("MMddyyyy",dat);
//easyDateFormat give you date in Date Format, pass datDate to the BAPI
public Date easyDateFormat (String format, String actualDate) {
Date datenewformat = null;
SimpleDateFormat formatter = new SimpleDateFormat(format);
try {
datenewformat = formatter.parse(actualDate);
} catch(ParseException e) {
return null;
}
return datenewformat;
}
Hope thsi help.
Regards,
Vito
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Samir,
Use the following steps
1. Use SimpleDateFormat to convert mm-dd-yyyy to util.date object
2. Convert util.Date object to String of form yyyymmdd again using SimpleDateFormat
3. BAPI uses Sql.Date... So convert the string (yyyymmdd) to sql.date using Date.valueOf(String) function
Regards
Smruti
*Reward if found useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Samir,
You can convert the frondend date as your wish. Create a object for SimpleDateFormat and parse the date as you want and send pass the required format to the BAPI.
For Example:
SimpleDateFormat isdf = new SimpleDateFormat("MM-dd-yyyy"); // For input format
Date dt=sdf.parse(strDate); // strDate is input from the frontend
Through this, you have converted the string(ie. strDate) into normal date format. From this you can get the required format as the following,
String result = null;
int dd=dt.getDate();
int MM=dt.getMonth()+1;
int year = dt.getYear()+1900;
result = yearMMdd+"";
Now, you have got the required format.
Regards,
Venkatesh. K
/* Consider Points if it is useful */
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.