Chinaunix

标题: 求两个日期之间差多少天 [打印本页]

作者: huangpengone    时间: 2007-09-03 13:35
标题: 求两个日期之间差多少天
final   long   DAY   =   3600*1000*24;   
                  DateFormat   f   =   new   SimpleDateFormat("yyyy-MM-dd");   
                  Date   d1   =   f.parse(f.format(new   Date()));   
                  Date   d2   =   f.parse("2005-11-1");   
                    
                  System.out.println((d1.getTime()-d2.getTime())/DAY);   
  ----------------   
  这个只用来求两个日期之间差多少天   
  final   long   DAY   =   3600*1000*24;是一天的milliseconds

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/20282/showart_373322.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2