String str=new SimpleDateFormat("yyyyMMddHH:mm:ss").format(new Date(System.currentTimeMillis()));
System.out.println(str);

解决方案 »

  1.   


        /**
         * Allocates a <code>Date</code> object and initializes it so that
         * it represents the time at which it was allocated, measured to the
         * nearest millisecond.
         *
         * @see     java.lang.System#currentTimeMillis()
         */
        public Date() {
            this(System.currentTimeMillis());
        }Date 的实现中,取得就是系统的默认毫秒数,如果就是currentTimeMillis 的话,那就直接new Date() 就可以了
    然后再将 new Date() 的值,通过 DateFormat 去转换 为需要的格式
      

  2.   


    public class Test { public static void main(String[] args) {
    Long l = System.currentTimeMillis();
    Date d = new Date(l);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    System.out.println(sdf.format(d));
    }}
      

  3.   

    long currentTime = System.currentTimeMillis();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
    Date date = new Date(currentTime);
    System.out.println(formatter.format(date));
      

  4.   

    SimpleDateFormat sdf= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");  
    long lSysTime1 = System.currentTimeMillis();
    java.util.Date dt = new Date(lSysTime1 );    
    String sDateTime = sdf.format(dt);  //得到精确到秒的表示:10/9/2014 21:08:00  
    System.out.println(sDateTime);