android - Its returning a error, but its in try-catch. Whats the error? -
my code want surrounded bt try-catch. did it, continue error
caused by: java.lang.nullpointerexception @ java.text.simpledateformat.parse(simpledateformat.java:1001) @ java.text.dateformat.parse(dateformat.java:624)
this code:
simpledateformat sdf = new simpledateformat("dd/mm/yyyy hh:mm"); try{ date date = sdf.parse(dataultima); dataultima = new simpledateformat("dd/mm/yyyy hh:mm").format(date); } catch (parseexception e) { // todo auto-generated catch block e.printstacktrace(); }
your code catching parseexception
, nullpointerexception won't handled catch clause. guess either sdf
null when code executes, or dataultima
null when passed parse method (i don't remember how parse()
responds null arguments).
you can solve in number of ways. check see if variable causing exception null before executing try block, add catch nullpointerexception
try/catch, or make parseexception
block catch more generic exception (like exception
) handle both cases (although not recommend it).
Comments
Post a Comment