"자바 System.currentTimeMillis()"의 두 판 사이의 차이

12번째 줄: 12번째 줄:
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='java' run>
<syntaxhighlight lang='java' run>
import java.text.SimpleDateFormat;
public class HelloWorld {
public class HelloWorld {
     public static void main(String [] args) {
     public static void main(String [] args) {

2021년 4월 17일 (토) 21:54 판

1 개요

Java System.currentTimeMillis()
  • 현재시각을 밀리세컨드 단위로 반환한다.
public class HelloWorld {
    public static void main(String [] args) {
        long millis = System.currentTimeMillis();
        System.out.println(millis); // 1491968593191
    }
}
import java.text.SimpleDateFormat;
public class HelloWorld {
    public static void main(String [] args) {
        long nano = System.currentTimeMillis();
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(nano)); // 2017-04-12 12:43:13.191
    }
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}