本帖最后由 王广亚 于 2013-9-23 21:35 编辑
- import java.text.*;
- import java.util.*;
- public class GetDate {
- public static void getdate(String d1, String d2) {
- long i = -1;
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- ParsePosition pos = new ParsePosition(0);//
- ParsePosition pos1 = new ParsePosition(0);//
- Date dt1 = formatter.parse(d1, pos);//
- Date dt2 = formatter.parse(d2, pos1);//
- long l = dt1.getTime()-dt2.getTime();
- i = l/(1000 * 60 * 60 * 24);
- System.out.println(i);
- }
- public static void main(String[] args){
- getdate("20013-05-04 00:00:00","2001-05-09 00:00:00");
- }
- }
复制代码 |