I am using The JXDatePicker in my Swing Application, and uses the following code to set the Date Value to the SQL Server Table
Date date = jDatePicker1.getDate();
String expectedPattern = "yyyy-MM-dd hh:mm:ss.SSS";
String currentFormat = "dd-MM-yyyy hh:mm:ss.SSS";
SimpleDateFormat dateFormatReq = new SimpleDateFormat(expectedPattern);
SimpleDateFormat dateFormatCurr = new SimpleDateFormat(currentFormat);
String strDate = dateFormatReq.format(dateFormatCurr.parse(dateFormatCurr.format(date)));
The problem is that the strDate value is '2011-04-01 12:00:00.000'
where as my requirement is '2011-04-01 00:00:00.000'
Any Help in the matter will be highly appreciable.
Use HH
instead of hh
for hours. Because HH
is "Hour in day (0-23)" and hh
is "Hour in am/pm (1-12)". See http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.