Goodmorning, 我將一個字符串解析爲一個大的十進制數,但是當我設置模式ans simbols時,調試器返回一個錯誤。代碼非常簡單,我從文檔和其他帖子在這裏的stackoverflow,我不記得它是什麼地址。它下面是:將字符串轉換爲bigdecimal時出錯
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setGroupingSeparator('.');
symbols.setDecimalSeparator(',');
String pattern = "#.##0,0#";
DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols);
decimalFormat.setParseBigDecimal(true);
(BigDecimal) decimalFormat.parse(entity.getQta()))
錯誤被拋出這一行:
com.smartgwt.client.core.JsObject$SGWT_WARN:
09:29:12.673:MOU6:WARN:RPCManager:ATTENZIONE: si e' verificato un errore imprevisto [SC: 500]undefined - response: {clientContext: Obj,
status: -1,
invalidateCache: true,
data: "ATTENZIONE: si e' verificato un errore i..."[59],
internalClientContext: Obj,
context: undef,
startRow: 0,
endRow: 0,
totalRows: 0} at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at
java.lang.reflect.Constructor.newInstance(Constructor.java:422) at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105) at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338) at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219) at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576) at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:304) at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.data.DataSource.processResponse(DataSource.java) at
com.sgss.common.client.ds.SgssGwtRpcDataSource.handleFailure(SgssGwtRpcDataSource.java:205) at
com.sgss.common.client.ds.SgssGwtRpcDataSource$GenericAsyncCallback.onFailure(SgssGwtRpcDataSource.java:148) at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:237) at
com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:259) at
com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412) at sun.reflect.GeneratedMethodAccessor417.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338) at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219) at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576) at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284) at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at
com.google.gwt.core.client.impl.Impl.entry0(Impl.java:356) at
sun.reflect.GeneratedMethodAccessor412.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293) at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Thread.java:745)
編輯:
DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols);
GWT調試程序的堆棧跟蹤我並沒有在GWT文件檔案(SmartGWT的我情況下,因爲我在後端解析,這不使用smartgwt,但只有春天和休眠。
請提供一個[mcve],其中應包含您要解析的值以及您的默認FORMAT語言環境。 –
只需將錯誤消息與您的問題一起發佈。 –
@Jon Skeet entity.getQta()是一個類似於1.743.711,67的字符串,並且語言環境是it_IT – softwareplay