import java.text.SimpleDateFormat;
import java.util.Date;
public void testString2Date() {
String startDate = "2017-08-15";
String endDate = "2017-08-15";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
int startDay = 0;
int endDay = 0;
try {
Date dateStart = format.parse(startDate);
Date datEnd = format.parse(endDate);
startDay = (int) (dateStart.getTime() / 1000);
endDay = (int) (datEnd.getTime() / 1000);
} catch (Exception e) {
e.printStackTrace();
}
System.err.println(startDay);
System.err.println(endDay);
}
虽千万人,吾往矣!