Chinaunix首页 | 论坛 | 博客

acc

  • 博客访问: 792104
  • 博文数量: 170
  • 博客积分: 7011
  • 博客等级: 少将
  • 技术积分: 1660
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-31 12:02
文章分类

全部博文(170)

文章存档

2014年(7)

2010年(2)

2009年(62)

2008年(25)

2007年(67)

2006年(7)

我的朋友

分类: Java

2007-04-29 09:12:21

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());
            }
}
}
阅读(2076) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~