データ型Big Decimalの列にStringを格納しようとしています。JAVAのConvertStringからBig Decimalへ
String a = transaction.getBeneAmt();
log.info(a);
tran.setTransAmt(new BigDecimal(transaction.getBeneAmt()));
tranRepository.saveAndFlush(trangloTran); //save into database
しかし、私はここでの問題は、あなたがNumberFormatException
を得た理由です、BigDecimal
に変換することはできませんので、あなたの文字列がアルファベット文字が含まれていることである
2017-07-05 18:04:19 [http-nio-8080-exec-1] INFO ApiController - IDR 3,000,000.00
2017-07-05 18:04:19 [http-nio-8080-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NumberFormatException] with root cause
java.lang.NumberFormatException: null
at java.math.BigDecimal.<init>(BigDecimal.java:494)
at java.math.BigDecimal.<init>(BigDecimal.java:383)
at java.math.BigDecimal.<init>(BigDecimal.java:806)
ジョン、あなたは本当に** Stringに**ビッグ進数に変換したいですか?あなたのコードで**文字列をBig Decimalに変換しようとしています** –
'a'の値はどれくらいですか? (それにはIDRが含まれていますか?)私はBigDecimalが何千もの区切り文字を扱うことはできないと思います。 –
https://stackoverflow.com/questions/13900204/bigdecimal-to-string類似の質問。 –