2017-07-12 8 views
1

Goodmorning、 文字列を大きな小数に解析していますが、パターンを設定するとエラーが返されます。コードは非常にシンプルで、私はドキュメンテーションと他のポストからここに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())) 

エラーがこのラインでスローされます。GWTデバッガの

DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols); 

のStackTrace:

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) 

編集:私は私の中にGWT(SMartGwtをmetionedませんでした私はバックエンドでこのような解析をしています。これはsmartgwtを使用せず、春と冬のみです。

+1

解析する値を含める[mcve]とデフォルトのFORMATロケールを入力してください。 –

+0

あなたの質問と一緒にエラーメッセージを投稿するだけです。 –

+0

@Jon Skeet entity.getQta()は、1.743.711,67のような文字列であり、ロケールはit_IT – softwareplay

答えて

2

ない文字通り - (タイトルのセクションで特殊パターン文字)ドキュメント https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html「」パターンで符号がグルーピングセパレータ用引当金に係る

String pattern = "#.##0,0#"; 

:N行で、間違っています番号のカンマ。 "。"小数点記号のために予約されていて、文字通りポイント文字ではありません。

数字が1.743.711,67の形式であり、1,743,711.67ではなく、記号変数を使用して小数点記号として「、」を指定しました。グループ化セパレータとして使用します。しかし、パターンは同じロジックに従いません。グループ化と小数点区切り文字の位置を入れ替えて失敗させます。

私はあなたが試すことをお勧めします。同じコードで

String pattern = "#,##0.0#"; 

、それが助けかどうかを確認します。

+0

ありがとう、私はそれを試してみます.. – softwareplay

+0

それはあなたを助けた場合、あなたは親切に答えを受け入れることができますか?そうでない場合は、私に知らせてください、私は試して助けます。 – Assafs

関連する問題