Hi Guillermo,
Get the BAPI exporting parameter in the String value say "strDate".
Convert this string value in the date using the following code:
SimpleDateFormat sdf = new SimpleDateFormat(strDate);
Date returnDate = sdf.parse(date);
The returnDate will be in the Date format.
Regards,
Prashil
Hi
U can do it by using SimpleDateFormat class.
Try this
String dtstr="4-10-2007";
<b>try</b>{
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
Date dt=sdf.parse(dtstr);
} <b>catch</b>(ParseException ex) {
System.out.println(ex);
}
Hope this will help u
Regards,
Nithya
Hi Guillermo,
one approach is to use the SimpleDateFormat formatter object (Javadoc herehttp://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html">here>) for your string value.
Here is a sample code:
public class StringToDate { public static void main(String[] args) { DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { Date today = df.parse("01/01/2007"); System.out.println("Jan 1st 2007 = " + df.format(today)); } catch (ParseException e) { e.printStackTrace(); } } }
Hope this helps.
Regards,
Joseph
Hi Guillermo another way for converting date format......
Wherever u want to convert date simply call this method..
public String strDate(Date objDate)
{
Calendar objCal=Calendar.getInstance();
objCal.setTime(objDate);
int intDate=objCal.get(Calendar.DATE);
int intMonth=objCal.get(Calendar.MONTH)+1;
int intYear=objCal.get(Calendar.YEAR);
return ""intDate"."intMonth"."+intYear;
}
And another process
StringTokenizer objstr1=new StringTokenizer(objstr,"-");
String year=objstr1.nextToken();
String month=objstr1.nextToken();
String total=objstr1.nextToken();
StringTokenizer objstr3=new StringTokenizer(total," ");
String date=objstr3.nextToken();
String Time=objstr3.nextToken();
String objstr2=""date"/"month"/"+year;
wherever u want to add date simply add objstr2....
Hope this is helpful to u......
Regards...
Sumalatha.....
Guillermo,
It appears that a lot of responses to your question are now just repetition...
Has the initial answer provided been of any value for you?
If yes, please consider closing this question and rewarding points for a helpful answer!
Thanks in advance!
Regards,
Joseph
Add a comment