posts - 14,  comments - 37,  trackbacks - 0
java的日期比较方法(精确到秒):
public boolean compDate(String s1,String s2){
        
int day=0
        SimpleDateFormat sf
=new SimpleDateFormat("yyyy-MM-dd");
        GregorianCalendar calendar1
=new GregorianCalendar();
        GregorianCalendar calendar2
=new GregorianCalendar();
        
//String s1="2006-04-21";
        
//String s2="2006-04-25";
        Date xxx1=new Date();
        Date xxx2
=new Date();
        
try {
            xxx1
=sf.parse(s1);
            xxx2
=sf.parse(s2);
            day 
= (int) ((xxx2.getTime() - xxx1.getTime()) / 3600 / 24 / 1000);
        }
 catch (ParseException e) {
            
// TODO Auto-generated catch block
            e.printStackTrace();
        }

        
if(day>10){
            
return true;
        }
else{
            
return false;
        }

        }
 
posted on 2007-07-11 13:06 冰封的爱 阅读(3247) 评论(0)  编辑  收藏 所属分类: 常用工具

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(3)

随笔档案

文章分类

文章档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜