본문 바로가기

JAVA / JSP

오늘 날짜 구하기

 

<%@ page c"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);
%>


오늘 <%= strdate%>

<%
Calendar cal = Calendar.getInstance();
%>

<p>
<%= cal.get(Calendar.YEAR) %>년
<%= cal.get(Calendar.MONTH) + 1 %>월
<%= cal.get(Calendar.DATE) %>일

 

 

==============================================================================================

<%@ page import="java.util.Date"%>
<%@ page import="java.text.DecimalFormat"%>
<%@ page import="java.text.SimpleDateFormat"%>

 

Date date = new Date();
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy");
int year = Integer.parseInt(simpleDate.format(date));
int selYear = (!"".equals(request.getParameter("selYear")) && request.getParameter("selYear") != null) ? Integer.parseInt(request.getParameter("selYear")) : year;