I want to store date in DB in e.g. 13/09/2016 06:48:23 format.
My DB table column datatype for "publishDate" column is Date.
In java I am doing as ,
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
String strDate = sdf.format(new Date());
System.out.println(strDate); //13/09/2016 06:48:23
But I want to store this String date into publishDate column which has Date datatype.
I tried like ,
Date publishDate = sdf.parse(strDate);
System.out.println(publishDate); //Tue Sep 13 06:48:23 IST 2016
Output is not in required format (required format is 13/09/2016 06:48:23).
Can someone please suggest what I am missing here.
Thanks in advance.