i am converting string in to date object in android...... that string is coming from server in form of "2014-02-22" or something like that... i want to convert it in to my date which i can use in my application.. i am using Simple Date Format ,parse method to convert.... but this statement throws parse exception... meaning its not converting my string.. which is "2014-02-22"... it should convert but its not.... so kindly help me in this..... i am getting null in response
@SuppressLint("SimpleDateFormat")
public static Date getDate(String string){
Date date = null;
try {
date = new Date();
date = new SimpleDateFormat("yyyy/MM/dd").parse(string);
}
catch (ParseException e) { e.printStackTrace(); }
catch (java.text.ParseException e) { e.printStackTrace(); }
return date;
}