on 07-16-2010 7:10 AM
Hi,
I need to pass today's date and time to RFC from webdynpro. how can i get today's date and time and i need the date in mm/dd/yyyy format. is there any standard format for time to pass to ECC system. Please help.
Thanks in advance.
Hi Jyothi,
Find below sample java code, you can use this in WDJ application:-
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
*
@author www.javadb.com
*/
public class Main {
public void convertDateToString() {
//you can use below code:-
Calendar calendar = Calendar.getInstance();//to get the date**
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");//to set the format**
try {
System.out.println("Today: " + dateFormat.format(calendar.getTime()));//to get the current date as per ur format**
} catch (Exception e) {
e.printStackTrace();
}
}
/**
@param args the command line arguments
*/
public static void main(String[] args) {
new Main().convertDateToString();
}
}
Hope this may help you.
Deepak!!!
Edited by: Deepak Arora on Jul 16, 2010 8:49 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Ask abap team to accept in other/change date format in backend or accept in string date.
SimpleDateFormat sqlformat = new SimpleDateFormat("MMddyyyy");
GregorianCalendar calendar = new GregorianCalendar();
//java.sql.Date sqlOriginal = new java.sql.Date(calendar.getTimeInMillis());
//System.out.println("Original Date as yyyy-MM-dd ::"+sqlOriginal);
String strdate = sqlformat.format(new java.sql.Date(calendar.getTimeInMillis()));
try{
long longDate = Long.valueOf(strdate).longValue();
java.sql.Date sqlDt = new java.sql.Date(longDate);
System.out.println(sqlDt.getTime());
}catch(Exception ex) {
System.out.println("Exception"+ex.getLocalizedMessage());
}
It will show as MMddyyy format. send MMddyyyy or yyyy-MM-dd to backend, ask abap team to accept in thse format, they will change it accordingly in backend.
Hope it will helps
Regards
Arun Jaiswal
Thanks for the answers.
deepak and Srinivas,
i have written the code just the way you said, it gives me the output "Fri Jul 16 00:00:00 GMT 2010". where as i need the date format mm/dd/yyyy.
Poojith,
the code which you have given gives different format. But i need to pass in mm/dd/yyyy format.
Arun,
your code is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Have you checked/tested it? Now try again..it is working fine from my side.
It is in MMddyyyy or yyyy-MM-dd, backend RFC should accept in this date format or accept it as string format.
public static void DateTest()
{
SimpleDateFormat sqlformat = new SimpleDateFormat("MMddyyyy");
GregorianCalendar calendar = new GregorianCalendar();
java.sql.Date sqlOriginal = new java.sql.Date(calendar.getTimeInMillis());
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Original Date as yyyy-MM-dd ::"+sqlOriginal);
String strdate = sqlformat.format(new java.sql.Date(calendar.getTimeInMillis()));
try{
long longDate = Long.valueOf(strdate).longValue();
java.sql.Date sqlDtFormatted = new java.sql.Date(longDate);
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Formated Date as MMddyyyy ::"+sqlDtFormatted.getTime());
}catch(Exception ex){
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Exception"+ex.getLocalizedMessage());
}
}
Hope it will helps
Regards
Arun Jaiswal
Edited by: Arun Jaiswal on Jul 16, 2010 3:26 PM
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
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.