赞
踩
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class Demo5 {
- public static void main(String[] args) throws ParseException {
-
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- Date start = simpleDateFormat.parse("2003-05-03");
-
- Date end = simpleDateFormat.parse("2003-05-09");//parse将日期解析为Date类型 p
- long time = start.getTime(); //Date类中的getTime方法将时间转为long的时间戳
- long time1 = end.getTime();
- long num = time1 - time; //long类型的数据可以进行减价操作
-
- System.out.println(num / 1000 / 60 / 60 / 24);
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。