I am getting a date value from jQuery-Calender UI that is giving me the date in string format “mm/dd/yy” e.g 09/16/2012. Now I want to convert this into timestamp format “yyy-MM-dd hh:mm:ss”. Because in the database I have an attribute of Timestamp data type. How can I do this?
Using $( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" })
I am accepting the input as dateFrom = "2012-09-27" but now I want to convert it into date format yyyy-MM-dd hh:mm:ss
But I am getting the exception “unparsable Date “.
I am using following code:
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
java.util.Date test1=new java.util.Date (sdf.format(dateFrom));
Assuming that you are using jquery’s DatePicker UI tool then you can initialize a datepicker with the dateFormat option.
Initialize the datepicker’s dateFormat:
Or, set the dateFormat option, after init:
Note that this only provides a Date, not a Time.