System.currentTimeMillis();是什么意思啊?用在哪方面的?

解决方案 »

  1.   

    取当前系统时间的毫秒, long 类型,记住!
    Calendar c = Calendar.getInstance();
    long time = c.getTimeInMillis();//跟这个一样的一样的,
      

  2.   

    System.currentTimeMillis();是什么意思啊?
    获取当前的毫秒数用在哪方面的?
    可以用来测试程序的运行时间。作为不重复的文件名。
      

  3.   

    long l=new Date().getTime();
    这个也一样
      

  4.   

    生成报表的时候,比如都是同一个报表叫report.pdf,那如果生成多几次,名字就可以这样起report+毫秒数.pdf,这样就不会重名,而且知道是哪个report.还有就是时间撮time stamp
      

  5.   

    currentTimeMillis()返回以毫秒为单位的当前时间。注意,当返回值的时间单位是毫秒时,值的粒度取决于基础操作系统,并且粒度可能更大。例如,许多操作系统以几十毫秒为单位测量时间。 
    请参阅 Date 类的描述,了解可能发生在“计算机时间”和协调世界时(UTC)之间的细微差异的讨论。 
    返回:
    当前时间与协调世界时 1970 年 1 月 1 日午夜之间的时间差(以毫秒为单位测量)。
      

  6.   

    用在哪方面的? 
    还能用在控制线程时间,刷新屏幕频率。
    time1 = System.currentTimeMillis();
    你所运行的程序
    time2 = System.currentTimeMillis();
    if (time2 - time1 < 60) {
    try {
    Thread.sleep(60 - (time2 - time1));
    } catch (InterruptedException e) {
         }
    }
      

  7.   

    获取当前时间,精确到毫秒,long型的~
      

  8.   

    获取当前时间,精确到毫秒
    可以用在测试代码的运行时间。long l1 = System.currentTimeMillis();
    //运行代码
    long l2 = System.currentTimeMillis();long l3 = l2 - l1;//代码的运行时间
      

  9.   

    这个实际上在 API DOC 上面已经说得很清楚了。在 JDK 5 中还增加了个 System.nanoTime() 也是类似的。
      

  10.   

    long 类型的
    返回运行时间·
      

  11.   

    返回以毫秒为单位的当前时间。注意,当返回值的时间单位是毫秒时,值的粒度取决于基础操作系统,并且粒度可能更大。例如,许多操作系统以几十毫秒为单位测量时间。 
    请参阅 Date 类的描述,了解可能发生在“计算机时间”和协调世界时(UTC)之间的细微差异的讨论。 
    返回:
    当前时间与协调世界时 1970 年 1 月 1 日午夜之间的时间差(以毫秒为单位测量)。
      

  12.   

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#currentTimeMillis()currentTimeMillispublic static long currentTimeMillis()    Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.    See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC).    Returns:
            the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
        See Also:
            Date
      

  13.   

    neng dian fen xuexi shiyonng ?
      

  14.   

    public class TestTime{
    public static void main(String[] args){
    String str = new String("0");
    long time1 = System.currentTimeMillis();
    for(int i=0;i<10000;i++){
    str += i;
    }
    long time2 = System.currentTimeMillis();
    System.out.println("for循环共用了" + (time2 - time1) + "毫秒。");
    }
    }1970年一月一日00:00:00:000到现在的毫秒数
      

  15.   

    用来获取系统的当前时间啊,不过返回的是一个LONG 值 
      

  16.   

    很多地方用。。最近我用的地方是上传 屏幕截图的时候 屏幕编号+时间戳(System.currentTimeMillis())的方式防止文件名重复。。也能知道上传时间
      

  17.   

    System.currentTimeMillis();
    这个不是取当前系统的毫秒数么?用处嘛,你得看需求啦,比如游戏这种的,里面应该有很多地方用到吧