[java] string , date 타입간의 변환

2021. 3. 24. 01:25Spring Boot

반응형

String -> Date 

String expiredAtTmp = fridgeBasketList.get(i).getExpiredAt();

DateFormat sdFormat = new SimpleDateFormat("yyyy.MM.dd");
Date expiredAt = sdFormat.parse(expiredAtTmp);

 

 

 

Date -> String

Date tmpDate = fridge.getExpiredAt();

DateFormat sdFormat = new SimpleDateFormat("yy.MM.dd");
String expiredAt = sdFormat.format(tmpDate)+"까지";

 

 

참고

sdw8001.tistory.com/130

 

junghn.tistory.com/entry/JAVA-%EC%9E%90%EB%B0%94-%EB%82%A0%EC%A7%9C-%ED%8F%AC%EB%A7%B7-%EB%B3%80%EA%B2%BD-%EB%B0%A9%EB%B2%95SimpleDateFormat-yyyyMMdd

 

m.blog.naver.com/PostView.nhn?blogId=nateen7248&logNo=220564458532&proxyReferer=https:%2F%2Fwww.google.com%2F

반응형