I have this code
public static void main(String[] args) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
String parsed = "15/07/2015";
java.util.Date date = format.parse(parsed);
java.sql.Date sql = new java.sql.Date(date.getTime());
System.out.println(sql);
}
where I am trying to get the date format as 15/07/2015 to insert into the DB. Whereas, everytime it provides me an output as 2015-07-15. I do not understand why is it so.
- Is it because the default date date formatting for
java.sql.Dateisyyyy-MM-dd.? - Or, do I need to set a different date format after parsing into
java.sql.Date?
Any suggestions or guidance would help. Thanks