cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot convert string to date

Former Member
0 Kudos

Hi,

I am creating a webdynpro application, with a DatePicker and 2 Input Fields called Start_Date and End_Date.

When i write the code it says "Cannot Convert from String to Date".

/*

Date Start = wdContext.currentDatepickElement().getStart();

SimpleDateFormat df = new SimpleDateFormat("DD/MM/YYYY");

Date End = wdContext.currentDatepickElement().getEnd();

SimpleDateFormat df = new SimpleDateFormat("DD/MM/YYYY");

*/

How can i get the Date which i selected into the two input fields?

Regards,

Divya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I changed the code to

String Start;

Date date;

SimpleDateFormat df = new SimpleDateFormat("DD/MM/YYYY");

date = (Date).df.parse(Start);

Start = wdContext.currentDatepickElement().getStart();

Endt = wdContext.currentDatepickElement().getEnd();

Giving me an error "Date cannot be resolved". The error is at line 5. How can i resolve this?

Regards,

Divya

Former Member
0 Kudos

try this

try{

String start= wdContext.currentDatepickElement().getStart();;

Date dtTmp = new SimpleDateFormat("MMM d, yyyy H:mm").parse(start);

String strOutDt = new SimpleDateFormat("MM/dd/yyyy").format(dtTmp);

System.out.println("String to date conversion:" + strOutDt);

}catch(Exception e){

}

reward points if helpful

Answers (0)