AndroidJava

자바(Java) 오늘 날짜 (SimpleDataFormat) 가져오기

자바 오늘 날짜

날짜 타입은 “yyyy-MM-dd” 이다.

public static String getToDay(){
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(new Date());
}

오늘 날짜와 시간 정보가 필요한 경우

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 

Leave a Reply

error: Content is protected !!