Skip to content

Instantly share code, notes, and snippets.

@ghostflare76
Last active October 25, 2019 08:41
Show Gist options
  • Save ghostflare76/f458554ac99cc728acafce621eb6f96d to your computer and use it in GitHub Desktop.
Save ghostflare76/f458554ac99cc728acafce621eb6f96d to your computer and use it in GitHub Desktop.
@Test
public void offsetTimeString_TO_LocalDateTime() {
// 표준ISO8601 타입으로 넘어오지 않는 경우 대응을 위해 구현
// ex)T 생략 , zoneOffSet 공백으로 구분되어 넘어옴
String offsetTimeString="2019-10-25 15:44:52.775 +09:00".replaceFirst(" ", "T").replace(" ", "");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
LocalDateTime localDateTime = OffsetDateTime.parse(offsetTimeString).toLocalDateTime();
System.out.println(localDateTime.format(formatter));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment