public static void main(String[] args) throws IOException, ParseException {
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS");
String format = dateFormat.format(date);
System.out.println(format);
Date time1 = dateFormat.parse("2014-03-06 01:02:03:105");
Date time2 = dateFormat.parse("2014-03-06 01:02:04:96");
long diff=time2.getTime()-time1.getTime();
System.out.println(diff);
//tfj();
}
直接上代码吧。