20070725T160000    怎么把它转为 毫秒,

解决方案 »

  1.   

    String str="20070725T160000";
    String[] a=str.split("T");
    String d=a[0];
    String t=a[1];
    FormatDate f=new FormatDate();
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    java.util.Date date1=new Date();
    try{
      date1=df.parse(d);
    }catch(Exception e){
     System.out.println(e);
    }
    long ms=date1.getTime()+Long.parseLong(t);
    搂主是这个意思吗?是的话,记得给分呀
      

  2.   

    如果 T 后面是时分秒的话,可以把 T 去掉,再进行解析:String str="20070725T160000";
    str = str.replace("T", "");
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
    Date date = df.parse(str);
    System.out.println(date.getTime());
      

  3.   

    bao110908(长牙了,好痛) ( ) 信誉:100 
    正解
      

  4.   

    String str="20070725T160000"; //分析你的时间格式
    String[] a=str.split("T");    //以“T”为分割符,分开T前和T后数据
    String times=a[0]+a[1];       //a[0]为T前部分,a[1]为T后部分,组合两字符串为times
    Calendar cal = Calendar.getInstance();//通过Calendar类来处理时间,先初始化该类
    Integer nian=new Integer(times.substring(0,4));//截取字符串转换为int类型
    Integer yue=new Integer(times.substring(4,6));//截取字符串转换为int类型
    Integer ri=new Integer(times.substring(6,8));//截取字符串转换为int类型
    Integer shi=new Integer(times.substring(8,10));//截取字符串转换为int类型
    Integer fen=new Integer(times.substring(10,12));//截取字符串转换为int类型
    Integer miao=new Integer(times.substring(12,14));//截取字符串转换为int类型
    cal.set(nian.intValue(),yue.intValue(),ri.intValue(),shi.intValue(),fen.intValue(),miao.intValue());//通过设置年月日时分秒
    cal.getTimeInMillis();//从Calendar类中的getTimeInMillis方法获得毫秒数
    注意:获得是毫秒数。
      

  5.   

    上边直接通过jdk提供的Calendar类来实现,通过这个类可以实现大多数的时间转换。
      

  6.   

    long haomiaoshu=cal.getTimeInMillis();//long型的毫秒数你可以进行处理
    毫秒数:haomiaoshu
    获得秒:haomiaoshu/1000
    获得分:haomiaoshu/1000/60
    获得时:haomiaoshu/1000/60/60注释很全了,应该很容易理解了。
      

  7.   

    to: zhao0p设置月时,需要减去 1 的,因为 1 月份是“0”。
      

  8.   

    new SimpleDateFormat("yyyyMMdd'T'HHmmss").parse("20070725T160000").getTime();
      

  9.   

    ->bao110908呵呵大意了!是应该减一