long ct=System.currentTimeMillis();// current time in milliseconds

解决方案 »

  1.   

    同意 wobelisk():
    @see System#currentTimeMillis()
    这是NATIVE方法实现的获取从1970-01-01 00:00:00至今的毫秒数(注意时区问题)。
      

  2.   

    使用java.text.SimpleDateFormat类即可。import java.util.Calendar;
    import java.util.Date;
    import java.text.SimpleDateFormat;public class test 
    {    
      public static void main(String args[]) 
      {
        //设置日期格式为'年年年年月月日日 时时:分分:秒秒.毫秒'
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
        //取得当前日期
        Date date = Calendar.getInstance().getTime();
        //格式化当前日期
        String time = sdf.format(date);
        System.out.println(time);
      }
    }