JSP로 오늘 날짜 출력하기
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import='java.text.SimpleDateFormat'%>
<%@ page import="java.util.Date"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>현재 시간</title>
</head>
<body>
<%
Date date = new Date();
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd");
String strDate = simpleDate.format(date);
%>
오늘 날짜는 <%=strDate%>입니다.
</body>
</html>
필요한 패키지를 import 해주어야 한다.
'최범균의 JSP 2.3 웹프로그래밍 > CH02 웹 프로그래밍 기초' 카테고리의 다른 글
01. 웹과 웹 프로그래밍 (0) | 2024.06.29 |
---|