The Java date and string are transferred to each other. Get the date and time of the last second of the day based on the day of the day
Package Com.hi;import Java.text.dateformat;import Java.text.parseexception;import Java.text.SimpleDateFormat; Import java.util.date;/** * Based on the day of the day * to get the last second of the day * database query very meaningful from the start day to the knot rate day by day query 2014-06-17 00:00:00 to 2014-06-20:23 : 59:59 * * @author Administrator * */public class Main3 {public static void main (string[] args) throws ParseException {Da Teformat format=new SimpleDateFormat ("YYYY-MM-DD");D ate d=new Date (); String Str=format.format (d); System.out.println (str);D ate d2=format.parse (str); System.out.println (D2);/////////////////gets the time to test all day int daymis=1000*60*60*24;//The millisecond of the day -1system.out.println (" The millisecond of the day-1: "+daymis");//Returns the number of milliseconds represented by this Date object since January 1, 1970 00:00:00 GMT. Long Curmillisecond=d2.gettime ();//millisecond System.out.println of the Day ("Curmillisecond:" +new Date (Curmillisecond)); long Resultmis=curmillisecond+ (DAYMIS-1); The last second of the day System.out.println ("Resultmis:" +resultmis);D Ateformat format2=new simpledateformat ("Yyyy-mm-dd HH:mm:ss") ;//Get the time I need the last second of the day date resultdate=new date (Resultmis); System.ouT.println ("Resultdate:" +resultdate); System.out.println ("FormatResult:" +format2.format (Resultdate));}} /** * Output:2014-06-17tue June 00:00:00 CST 20,141-day millisecond -1:86400000curmillisecond:tue June 00:00:00 CST 2014resultmis:14 03020799999resultdate:tue June 23:59:59 CST 2014formatresult:2014-06-17 23:59:59*/
Java date and string, based on the day of the day to get the date and time of the last second of the day