I wanted to calculate the processing time based on the start date and end date.
date.java
import java.text.SimpleDateFormat;
import java.util.Date;
public class date {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date start = null;
Date end = null;
//Convert to Date type
try {
start = sdf.parse("2020/03/23 12:30:12");
end = sdf.parse("2020/03/23 12:31:12");
} catch (java.text.ParseException e) {
e.printStackTrace();
}
long timeStart = start.getTime();
long timeEnd = end.getTime();
long processTime = timeEnd - timeStart;
//millisecond
System.out.println(processTime);
}
}
Execution result:
60000
Recommended Posts