자바 Date Format 변경하기(SimpleDateFormat) 본문
자바에서 Date 객체를 사용해 날짜를 생성하여 yyyy-mm-dd 형식으로 출력하는 방법입니다.
SimpleDateFormat 을 사용하면 간단하게 변환할 수 있습니다.
1 2 3 4 5 | Date newDate = new Date(); SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); String newDateString = format1.format(newDate).toString(); | cs |
SimpleDateFormat 형식을 다양하게 설정할 수도 있습니다.
'Java' 카테고리의 다른 글
브라우저별 한글 파일명 인코딩하기(엣지 추가) (0) | 2019.05.02 |
---|
Comments