on 06-05-2007 10:11 AM
Hi folks,
i'm facing a problem, when passing parameter to BAPI.
i have declare date as java.util.date, i need to change declaration to java.sql.date, anyone know?
Chandan , i get an error message java.lang.IllegalArgumentException for java.sql.Date.valueOf, below is my code :
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-mm-dd") ;
String S_startdate = wdContext.currentContextElement().getStartDate();
String S_enddate = wdContext.currentContextElement().getEndDate();
java.util.Date D_startdate;
try {
D_startdate = sdf.parse(S_startdate);
S_startdate = sdf.format(D_startdate);
} catch (ParseException e1) {
e1.printStackTrace();
}
java.util.Date D_enddate;
try {
D_enddate = sdf.parse(S_enddate);
S_enddate =sdf.format(D_enddate);
} catch (ParseException e2) {
e2.printStackTrace();
}
java.sql.Date startdate = java.sql.Date.valueOf(S_startdate);
java.sql.Date enddate = java.sql.Date.valueOf(S_startdate);
do you know what's wrong with this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Before executing the BAPI set the varaible date to sql date using following
Date sqlDate = new Date(utildate.getTime());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think this will help you.
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Date;
...
String dateString = "18/08/2005";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date d;
try {
d = dateFormat.parse(dateString);
dateFormat.applyPattern("yyyy-MM-dd");
dateString = dateFormat.format(d);
} catch (Exception e) {
e.printStackTrace();
}
java.sql.Date date = java.sql.Date.valueOf(dateString);
System.out.println(date);
Thanks and Regards
Chandan
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 convert java.util.date to java.sql.date. Do this conversion before calling the BAPI.
//say <i>date</i> is the "java.util.date" variable
java.sql.Date sqlDate = new java.sql.Date( date.getTime() );
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
can u explain me clearly.....did u write any code ?if there post me.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
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.