Notice
Recent Posts
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Eclipse
- 자바
- 버튼
- jquery
- 면접
- 스프링
- 깃허브 간단요약
- html
- jsp 내부객체
- jsp
- 설정
- 자바스크립트
- Spring
- 제이쿼리
- java
- SESSION
- springboot
- 필터체인
- 알고리즘
- 설치
- 셋업
- 깃허브
- EL태그
- 마이바티스
- MySQL
- 폼태그
- 오라클
- jstl
- Oracle
- 이클립스
Archives
- Today
- Total
은은하게 코드 뿌시기
자바 날짜비교 / 날짜계산/날짜수정/기간체크 본문
728x90
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.KOREA);
//01. 날짜 형식 포매터로 선언하기
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
LocalDate currentDate = LocalDate.now();
//02.받아온날짜 포매터로 변환하기 받아온날짜형식은 2024-09-26 17:26:23 포매터와 동일
String date1 = product1.getStr("받아온날짜");
LocalDateTime compareDateTime = LocalDateTime.parse(date1, formatter);
//03. locaDatetime 자바에서 기간체크 하기
Boolean reuslt = compareDateTime.isBefore(nowdatetime) && compareDateTime.plusMonths(1).isAfter(nowdatetime);
// 오늘보다 이전이고, 설정날짜에 + 한달이 오늘보다 이후인지.
product1.put("newlabel", reuslt);
//04. 날짜 수정하기
scheckdates = nowdatetime.plusWeeks(2).format(formatterM);
scheckdatee = nowdatetime.plusWeeks(2).plusMonths(4).format(formatterM);
string으로 받아서
formatter로 변환해서 localdatetime으로 받아서
비교하면됨.
728x90
'자바 > 실무 유용한 것!' 카테고리의 다른 글
크로스 조인 / 자바 / rownum (0) | 2024.09.27 |
---|---|
encodeURIComponent 이거랑 escape 차이? (0) | 2024.09.25 |
통화 포맷 / java 원단위/krw (0) | 2024.06.17 |
java integer string으로 쉽게바꾸기 (0) | 2024.05.29 |
크롬 단축키 (0) | 2024.05.14 |
Comments