ページの作成:「System<br>」
 
編集の要約なし
 
(同じ利用者による、間の4版が非表示)
1行目: 1行目:
[[System]]<br>
[[System]].currentTimeMillis [https://docs.oracle.com/javase/jp/8/docs/api/java/lang/System.html#currentTimeMillis--]
 
現在のUNIX時間を取得します。戻り値の時間単位はミリ秒ですが、値の粒度は基本となるオペレーティング・システムによって異なり、単位がより大きくなる場合があります。たとえば、多くのオペレーティング・システムでは、時間を10ミリ秒の単位で計測します。
 
long start = System.currentTimeMillis();
        for (int i = 0; i < 10_000_000; i++) {
            System.out.println(i + ": Hello!");
        } 
long end = System.currentTimeMillis();
System.out.println("Time: " + (end - start) + "msecs");

2019年6月10日 (月) 12:33時点における最新版

System.currentTimeMillis [1]

現在のUNIX時間を取得します。戻り値の時間単位はミリ秒ですが、値の粒度は基本となるオペレーティング・システムによって異なり、単位がより大きくなる場合があります。たとえば、多くのオペレーティング・システムでは、時間を10ミリ秒の単位で計測します。

long start = System.currentTimeMillis();
       for (int i = 0; i < 10_000_000; i++) {
           System.out.println(i + ": Hello!");
       }   
long end = System.currentTimeMillis();
System.out.println("Time: " + (end - start) + "msecs");