[Java] LocalDate, LocalDateTime 날짜 차이 계산
2022. 11. 11. 20:12
프로그래밍/JAVA
LocalDate 날짜 차이 계산하기 Period LocalDate startDate = LocalDate.of(2020, 11, 10); LocalDate endDate = LocalDate.of(2022, 11, 20); Period period = Period.between(startDate, endDate); log.debug("Days : {}", period.getDays()); // Days : 10 LocalDateTime 날짜 차이 계산하기 ChronoUnit Duration과 Period 객체를 생성하지 않고 특정 시간 단위로 차이를 구하는 방법 LocalDateTime startDateTime = LocalDateTime.of(2020, 12, 20, 9, 30, 30); LocalD..

[IntelliJ] 인텔리제이에서 스프링부트 Devtools가 실행되지 않을 때
2022. 11. 10. 20:37
IDE/IntelliJ
Devtools를 bulid.gradle 파일의 dependencies에 추가해줬는데 작동하지 않는 경우 implementation 'org.springframework.boot:spring-boot-devtools' 1. Preferences > Build, Execution, Deployment > Compiler ✅ Build project automatically 2. Preferences > Advanced Settings ✅ Show only line bookmarks in popup Devtools가 정상 작동함👏
[GitHub] fork된 repository 삭제
2022. 11. 9. 20:46
형상관리/Git
GitHub에서 fork된 repository 삭제하기 fork된 repository 클릭 Settings 클릭 Danger Zone에서 "Delete this repository" 버튼 클릭 🚫 주의할 점은 로그인 아이디가 fork된 repository를 삭제하고 싶은 아이디가 맞는 지 확인해야 함
[React] 리액트 조건문
2022. 11. 8. 20:43
프로그래밍/React
JSX 안의 삼항 연산자 조건문 ? 조건문 참일때 실행할 코드 : 거짓일 때 실행할 코드 이 형식에 맞춰 쓰면 됨 function Component() { return ( { 1 === 1 ? 참이면 보여줄 HTML : null } ) } JSX 내에서 if/else 대신 쓸 수 있음 삼항연산자는 그냥 if와는 다르게 JSX 안에서도 실행가능하며 조건을 간단히 주고 싶을 때 사용 간단한 조건문 더보기 (문법) 자바스크립트에선 &&연산자라는게 있음 "왼쪽 오른쪽 둘다 true면 전체를 true로 바꿔주세요~" 라고 쓰고싶을 때 씀 true && false; true && true; 맨 위의 코드는 그 자리에 false가 남고 밑의 코드는 true가 남음 근데 자바스크립트는 && 기호로 비교할 때 true와..
[Java Error] java list add 시 null pointer exception
2022. 11. 7. 20:36
프로그래밍/JAVA
java list add 시 null pointer excetpion list 생성시 List longList = null; longList.add(2L); 이렇게 작성하지 말고 List longList = new ArrayList(); longList.add(2L); 위와 같이 선언하기
[Java] Stream reduce 사용법 및 예제
2022. 11. 4. 20:50
프로그래밍/JAVA
Stream :: reduce 사용법 reduce는 stream의 데이터를 하나의 요소로 만드는 작업을 수행 쉽게 stream의 마지막 요소를 가져오고 싶을 때도 활용할 수 있음 👉 알아보기 다양한 예제 List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); int result = numbers .stream() .reduce(0, (subtotal, element) -> subtotal + element); assertThat(result).isEqualTo(21); List letters = Arrays.asList("a", "b", "c", "d", "e"); String result = letters .stream() .reduce("", (partialString,..
[Java] Stream 마지막 요소 가져오기
2022. 11. 3. 20:43
프로그래밍/JAVA
간단하게 Stream 마지막 요소 가져오기 Stream :: reduce 메서드 이용 Stream stream = ...; // sequential or parallel stream Optional last = stream.reduce((first, second) -> second); 실제 사용 예시 Order endDate = sortOrderProductList .stream() .reduce((first, second) -> second).get() .getEndDate(); Stream :: reduce 사용법 reduce는 stream의 데이터를 하나의 요소로 만드는 작업을 수행 List numbers = Arrays.asList(1, 2, 3, 4, 5, 6); int result = numb..
[Git Error] git branch 삭제 안될 때 Cannot delete branch
2022. 11. 2. 21:24
형상관리/Git
깃 브랜치 삭제 기본 명령어 git branch -D dev error: Cannot delete branch 'dev' checked out at '경로' 오류 발생 해결 방법 현재 브랜치가 삭제하고자 하는 브랜치이기에 브랜치 전환 후 삭제 git checkout main git branch -D dev