Programming/Java
[Java] Date , String 간의 변환방법
By훈트
2011. 3. 7. 11:13
String -> Date 타입
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date tempDate = sdFormat.parse("20100222");
주의할 점..
" " 내부에 들어가는 내용대로 String 데이터가 입력되어 있어야 파싱이 된다.
Date -> String 타입
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = new Date();
String tempDate = sdFormat.format(nowDate);
주의할 점..
" " 내부에 들어가는 내용대로 포멧되어 String 데이터로 리턴된다.
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date tempDate = sdFormat.parse("20100222");
주의할 점..
" " 내부에 들어가는 내용대로 String 데이터가 입력되어 있어야 파싱이 된다.
Date -> String 타입
DateFormat sdFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = new Date();
String tempDate = sdFormat.format(nowDate);
주의할 점..
" " 내부에 들어가는 내용대로 포멧되어 String 데이터로 리턴된다.