[TIL] 20240718 stream / DateTime

Jimin·2024년 7월 18일
0

TIL

목록 보기
2/2
post-thumbnail

Stream 사용법

map 사용법

원래 코드

List<ScreenSpaceSequenceStatusResponse> screenSpaceSequenceStatusResponseList = new ArrayList<>(); 
for(ClientScreenSequenceResponse screenSequence: screenSequenceList) {
            screenSpaceSequenceStatusResponseList.add(makeScreenSpaceSequenceStatusResponseObject(screenSequence));
 }

stream map 사용한 코드

List<ScreenSpaceSequenceStatusResponse> screenSpaceSequenceStatusResponseList = screenSequenceList.stream()
    .map(this::makeScreenSpaceSequenceStatusResponseObject)
    .toList();

DateTime으로 요청값 받기

@RequestParam

@DateTimeFormat(pattern = "yyyyMMdd")

@Parameter(description = "일자", example = "20240527", required = false)
@RequestParam(value = "yearMonthDay", required = true)
@DateTimeFormat(pattern = "yyyyMMdd")
LocalDate yearMonthDay;

@RequestBody

@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonFormat(pattern = "yyyyMMdd")

@NotNull
@Schema(description="일자", example="20230402", nullable=false, type="20240611")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonFormat(pattern = "yyyyMMdd")
private LocalDate yearMonthDay;
profile
https://github.com/Dingadung

0개의 댓글