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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -