I have a date coming in. So for example 02/16/2012. What I need to do in order to work with my database format is convert it to 2012-02-16. I figured this would be pretty straightforward. But I can’t work it. Here is my date parser.
String endDateString = "02/16/2012"
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
endDate = dateFormat.parse(endDateString)
Any suggestions? Thanks.
You should parse it FROM one correct format, then convert TO string with another correct format. What are you doing — is trying to interpret date in
MM/dd/yyyyformat withyyyy-MM-ddformat, i.e. incorrect.SAMPLE