Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to convert String like "7,00" to "7.00"

Hi Experts,

I have to convert String from "7,00" to "7.00". I tried using replace funtion. However it is not working.

The code is as below. Am I supposed to use some different Java function?

IPrivateTimesheetView.ICategoriesElement categoryElement;

String wbs ="h";

double d =0;

String sum_hrs ="";

for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){

wdContext.nodeWorklist().setLeadSelection(i);

categoryElement = wdContext.createCategoriesElement();

wbs = wdContext.currentWorklistElement().getReciever_Wbs_Element();

sum_hrs = wdContext.currentWorklistElement().getSum_Hours();

sum_hrs = sum_hrs.replace(",",".");

if( sum_hrs != null && sum_hrs.trim().length()>0)

d = Double.parseDouble(sum_hrs) ;

categoryElement.setCategoryText(wbs);

categoryElement.setSeries1Value(d);

wdContext.nodeCategories().addElement(categoryElement);

wbs = "";

The error message is

java.lang.NoSuchMethodError: java.lang.String.replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

at com.sastech.app.models.TimesheetView.onActionFindRecord(TimesheetView.java:253)

at com.sastech.app.models.wdp.InternalTimesheetView.wdInvokeEventHandler(InternalTimesheetView.java:365)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)

... 26 more

Can you please help me?

Regards,

S

Former Member
replied

Hi,

If you want to pass string then better use replaceAll instead of replace.

Ashutosh

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question