Android

[java, android] java.lang.NumberFormatException: multiple points

데이터 형변환 오류!!

java.lang.NumberFormatException: multiple points
2020-06-18 08:41:06.792 24116-24116/ddolcat.test W/System.err:     at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1914)
2020-06-18 08:41:06.792 24116-24116/ddolcat.test W/System.err:     at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
2020-06-18 08:41:06.793 24116-24116/ddolcat.test W/System.err:     at java.lang.Double.parseDouble(Double.java:538)
2020-06-18 08:41:06.793 24116-24116/ddolcat.test W/System.err:     at com.google.gson.stream.JsonReader.nextDouble(JsonReader.java:918)
2020-06-18 08:41:06.793 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson$3.read(Gson.java:277)
2020-06-18 08:41:06.793 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson$3.read(Gson.java:271)
2020-06-18 08:41:06.794 24116-24116/ddolcat.test W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116)
2020-06-18 08:41:06.794 24116-24116/ddolcat.test W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216)
2020-06-18 08:41:06.794 24116-24116/ddolcat.test W/System.err:     at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:879)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:844)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:793)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:765)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at ddolcat.test.MapsActivity.onSuccess(MapsActivity.java:1392)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at ddolcat.test.network.NetworkManagement$1.onResponse(NetworkManagement.java:159)
2020-06-18 08:41:06.814 24116-24116/ddolcat.test W/System.err:     at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
2020-06-18 08:41:06.815 24116-24116/ddolcat.test W/System.err:     at android.os.Handler.handleCallback(Handler.java:883)
2020-06-18 08:41:06.815 24116-24116/ddolcat.test W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:100)
2020-06-18 08:41:06.816 24116-24116/ddolcat.test W/System.err:     at android.os.Looper.loop(Looper.java:214)
2020-06-18 08:41:06.819 24116-24116/ddolcat.test W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7356)
2020-06-18 08:41:06.820 24116-24116/ddolcat.test W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-06-18 08:41:06.820 24116-24116/ddolcat.test W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2020-06-18 08:41:06.820 24116-24116/ddolcat.test W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

오류 발생원인 : 문자열(string) 값을 Double로 형변환할때 문자열이 잘못된 경우에 발생한다. 오류 내용에서 알 수 있듯이 멀티포인트가 문제이다. 문자열에 점이 한개 이상이라는 뜻이다. 

오류가 발생한 문자열은 다음과 같다.

 

String tempStr = “127.126.793015”;

 

데이터 타입 형변환을 할때 포인트(점)은 하나이어야만 한다!!

올바른 데이터는 다음과 같다.

String tempStr = “127.126793015”;

String tempStr = “127126.793015”;

Leave a Reply

error: Content is protected !!