Java

[Java] Date 객체 활용한 현재시간 가져오기

IT공부블로그 2020. 4. 1. 18:33
728x90
반응형
1
2
3
4
5
6
7
8
public String getCurrentTime() {
    //HH:mm:ss -> 0~24시  hh:mm:ss -> 0~12시
    //yyyy-MM-dd HH:mm:ss
    SimpleDateFormat formatter = new SimpleDateFormat ("HH:mm:ss");
    Date date = new Date();
    String time = formatter.format(date);
    return time;
}

cs


728x90
반응형