Language/java소스

date 타입 문자열 파싱하다가 안될 때

아라한사 2020. 12. 11. 10:49

DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.appendPattern("EEE MMM dd HH:mm:ss zzz yyyy")
.parseDefaulting(ChronoField.YEAR, 2020)
.toFormatter(Locale.US);

ZonedDateTime eee_mmm_dd = ZonedDateTime.parse("Thu Dec 10 12:30:43 KST 2019", formatter);

 

이런 형태로 빌더를 써서 해결해주면 된다

 

https://stackoverflow.com/a/58313379 

 

mkyong.com/java8/java-8-how-to-parse-date-with-dd-mmm-02-jan-without-year/

 

Java 8 - How to parse date with "dd MMM" (02 Jan), without year? - Mkyong.com

- Java 8 - How to parse date with "dd MMM" (02 Jan), without year?

mkyong.com