如:
1277106667 => 2010-06-21 15:51:07

解决方案 »

  1.   

    喔,原来是秒数....
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
    String date = sdf.format(new Date(时间戳*1000));
    System.out.println(date);
      

  2.   

    不好意思,有两个小修正SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    String date = sdf.format(new Date(时间戳*1000L));
    System.out.println(date);
      

  3.   

    你这是将格林时间的毫秒转化成字符串public String convert(long mill){
    Date date=new Date(mill);
    String strs="";
    try {
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    strs=sdf.format(date);
    } catch (Exception e) {
    e.printStackTrace();
    }
    return strs;
    }
      

  4.   

    long nowTime=System.currentTimeMillis();
    System.out.println(test.convert(nowTime));结果  2010-06-21 04:16:16
      

  5.   


    long time=1277106667;
    Date date=new Date(time);
    SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String str=format.format(date);
    System.out.println(str);结果是:1970-01-16 02:45:06  为什么不是2010-06-21 15:51:07呢
      

  6.   

    sorry。原来是秒数,不是毫秒数啊~
      

  7.   

    SimpleDateFormat 应该import哪个包呢?
    为什么我编译的时候说找不到符号SimpleDateFormat呢?
      

  8.   

    import java.text.SimpleDateFormat;
      

  9.   

    String str = String.format("%tF %<tT", 1277106667000L);PS:你那个时间戳少了三个“0”。代码在 JDK 1.5 及以上版本有效。
      

  10.   

    long数字就是距离1970年1月1日0:0:0的描述 大概就是这个意思。
      

  11.   

    不考虑多线程就用SimpleDateFormat
    考虑多线程用 FastDateFormat