java - String("2013-4-25") to date conversion -


i have string "2013-4-25" need convert "mm-dd-yyyy" format. later have append date like

calendar cal=new gregoriancalendar(); cal.settime(date); cal.set(calendar.hour, 23); cal.set(calendar.minute, 59); cal.set(calendar.second, 59); 

how this?

use this

string str = "2013-4-25";         simpledateformat formatter = new simpledateformat("mm-dd-yyyy");         try {             simpledateformat parseformatter = new simpledateformat("yyyy-mm-dd");              date date = parseformatter.parse(str);              string formatteddate = formatter.format(date);             system.out.println(formatteddate);         } catch (parseexception e) {             // todo auto-generated catch block             e.printstacktrace();         } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -