java - Having issues troubleshooting this error: Unparseable date: "June 17, 1985 11:33:00 UTC" -


this question has answer here:

this appears occur on small portion of users devices, cannot reproduce issue blowing crashlytics reports.

non-fatal exception: java.text.parseexception: unparseable date: "june 17, 1985 11:33:00 utc" (at offset 0)    @ java.text.dateformat.parse(dateformat.java:579)    @ me.calebjones.spacelaunchnow.content.services.launchdataservice.parsepreviousresult(launchdataservice.java:548)    @ me.calebjones.spacelaunchnow.content.services.launchdataservice.getpreviouslaunches(launchdataservice.java:243)    @ me.calebjones.spacelaunchnow.content.services.launchdataservice.onhandleintent(launchdataservice.java:115)    @ android.app.intentservice$servicehandler.handlemessage(intentservice.java:66)    @ android.os.handler.dispatchmessage(handler.java:102)    @ android.os.looper.loop(looper.java:148)    @ android.os.handlerthread.run(handlerthread.java:61) 

there's multiple dates seems stuck on in same format. here's code parsing it.

        simpledateformat df = new simpledateformat("mmmm dd, yyyy kk:mm:ss zzz");         df.tolocalizedpattern();          jsonobject response = new jsonobject(result);         jsonarray launchesarray = response.optjsonarray("launches");          (int = 0; < launchesarray.length(); i++) {             try {                 launch.setlaunchdate(df.parse(launchesobj.optstring("net")));             } catch (parseexception e) {                 launch.setlaunchdate(null);             }         } 

feel free take @ source here: https://github.com/caman9119/spacelaunchnow/blob/master/mobile/src/main/java/me/calebjones/spacelaunchnow/content/services/launchdataservice.java

setting locale fixed issue.

simpledateformat df = new simpledateformat("mmmm dd, yyyy kk:mm:ss zzz", locale.us); 

Comments