import java.text.SimpleDateFormat;
import java.util.Date;
public class EG {
/**
* @param args
*/
public static void main(String[] args) {
String s1 = "2002/09/14 15:48:37";
String s2 = "2002/09/14 14:18:37";
try{
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss");
// ParsePosition pos = new ParsePosition(0);
// ParsePosition pos1 = new ParsePosition(0);
Date dt1=formatter.parse(s1);
Date dt2=formatter.parse(s2);
System.out.println("dt1="+dt1);
System.out.println("dt2="+dt2);
long l = dt1.getTime() - dt2.getTime();
// long l1=dt1.getDate()-dt2.getDate();
// System.out.println("Hello World!="+new Date(l).toLocaleString());
System.out.println("Hello World!="+l/1000/60/60);
}catch(Exception e){
System.out.println("exception"+e.toString());
}
}
}
阅读(2106) | 评论(0) | 转发(0) |