i have done something similar to it. Follow it
*****
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd MMM yyyy");
Date date = dateFormatter.parse("21 JAN 2004");
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
String rqlDate = cal.get(Calendar.YEAR)+"-"+((cal.get(Calendar.MONTH))+1)+"-"+cal.get(Calendar.DATE);
******
the rqlDate value will be "2004-01-21"
Browse the above classes GregorianCalendar , Date for more information