Languages/Java
JAVA-현재 시간의 날짜 간단하게 표현하기
조미남
2013. 3. 7. 23:49
JAVA 의 System 클래스와 Calendar, SimpleDateFormat 클래스를 이용하여, 현재 날짜 및 시간을 가져올 수 있습니다.
- 간단하게 아래와 같이 작성할 수 있고,
1: long startTime = System.currentTimeMills();
2: System.out.println("현재 시간: " + new Timestamp(startTime());
- 혹은 아래와 같이 사용자의 편의에 따라 사용할 수 있습니다.
1: Calendar calendar = Calendar.getInstance();2:3: SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");4:5: System.out.println("현재 시간: " + dateFormat.format(calendar.getTime());