Web/Jsp
[JSP] LocaleDate 함수 사용하기+Include
jinnkim
2022. 2. 1. 10:30
전 게시물 SimpleDateFormat 함수를 활용한 날짜 출력하기에 이어 LocaleDate 함수 사용하여 날짜 출력하기!
구현

코드
1. include
<%@page import="java.time.LocalDateTime"%>
<%@page import="java.time.LocalDate"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>날짜출력</title>
</head>
<body>
<%
LocalDate today = LocalDate.now(); //오늘 날짜
LocalDate tomorrow = LocalDate.now().plusDays(1); //내일 날짜
//plusDays()태그 안에 출력할 날짜 기간 입력
%>
</body>
</html>
2. include 파일 포함
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="includeFile.jsp" %> <!-- 윗 JSP 파일 링크 포함 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>include</title>
</head>
<body>
<%
out.println("오늘 날짜 : " + today);
out.println("<br/>");
out.println("내일 날짜 : " + tomorrow);
%>
</body>
</html>
< 공부하기 >
1. Include (Include Directive Tag)
- 공통으로 사용하는 JSP 페이지를 다른 JSP 페이지에 추가할때 사용
- 재사용성이 높음
- JSP 페이지 유지관리가 쉬움
2. LocaleDateDate
- 날짜, 시간 정보 출력할때 사용함