android - Want to convert a date from the format"dd-mmm-yyyy" to "yyyy-mm-dd". And here is my code -
i want convert date format"dd-mmm-yyyy" "yyyy-mm-dd". , here code.
public void convertdate(){ gregoriancalendar todaysdate = (gregoriancalendar) month.clone(); // show error on here. simpledateformat df = new simpledateformat("dd-mmm-yyyy", locale.us); currentdatestring = df.format(todaysdate.gettime()); try{ date tdate3= df.parse(currentdatestring); tdate4=targetdateformat.format(tdate3); } catch (parseexception e) { log.e(getpackagename(), e.getmessage()); e.printstacktrace(); }
but problem showing nullpointer exception . , not able understand mistake. please if can ?
try :
date cdate = new date(); dateformat inputformat = new simpledateformat("yyyy-mm-dd"); date date = dateformat.parse(cdate);
hope you.
Comments
Post a Comment