Today ate the time format of the big loss, but also do not understand the time format of JS, pit for a long time. Remember, a long memory to share with you.
Java date formatting: Remember that the format is Yyyy-mm-dd HH:MM:SS, which is case-sensitive.
public static void Main (string[] args) {
//correct time format
String ddate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"). Format (new Date ());
Error time format
String ddate1 = new SimpleDateFormat ("Yyyy-mm-dd HH:MM:ss"). Format (new Date ());
System.out.println (ddate);
2015-12-30 14:02:56
System.out.println (ddate1);
2015-02-30 14:12:56
}
JS Date format: Remember that the JS format is YYYY-MM-DD hh:mm:ss, are lowercase. Strictly case sensitive.
(new Date ()). Format ("Yyyy-mm-dd")
"2015-12-30"
(new Date ()). Format ("Yyyy-mm-dd")
"2015-51-30"
(new Date (1451444616000)). Format ("Yyyy-mm-dd hh:mm:ss")
"2015-12-30 11:12:36"
( 1451444616000). Format ("Yyyy-mm-dd hh:MM:ss")
"2015-03-30 11:03:36"
Error occurs because:
Because the data used is the datetime type, from the background to get data to the foreground, the display date format to 1451444616000, after YYYY-MM-DD HH:mm:ss format, found that the time is not right, Instead of the date data displayed through the Navicat query 2015-12-30 11:12:36. Because of the JS time format used in the same way as Java, showing the wrong time, leading to the search no problem. Finally a careful examination, only to understand the format is not uniform.
Finally, note:
Java Time formatting:
New SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"). Format (new Date ())
JS Time Format:
(New Date ()). Format ("Yyyy-mm-dd hh:mm:ss")