Programming/Java & JSP & Spring
[Java] String, Date 타입 간의 변환
henry-jo
2017. 8. 17. 15:06
String 》》 Date
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date tempDate = sdFormat.parse("20170817");
※ 주의할 점 : 포맷 타입에 맞게 String 데이터가 입력되어야 파싱이 된다.
Date 》》 String
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = new Date();
String tempDate = sdFormat.format(nowDate);
※ 주의할 점 : 포맷 형식대로 리턴된다.
※ 출처 : http://sdw8001.tistory.com/130