본문 바로가기
Web Programing!/JAVA / JSP

[JSP] 현재 날짜 구하기

by 어설픈봉봉이 2011. 7. 8.
반응형
SMALL


<%@ page contentType="text/html; charset=euc-kr" %>
<%@ page import="java.util.*, java.text.*" %>

   <%
      Date date = new Date();
      SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd");
      String strdate = simpleDate.format(date);
   %>
   보통의 JSP 페이지의 형태입니다.<br>
   오늘 날짜는 <%= strdate%> 입니다.

   <%
      Calendar cal = Calendar.getInstance();
   %>
  
   <p>
   오늘은
   <%= cal.get(Calendar.YEAR) %>년
   <%= cal.get(Calendar.MONTH) + 1 %>월
   <%= cal.get(Calendar.DATE) %>일
   입니다.


반응형