관리 메뉴

I LOVE EJ

지정된 날짜에 +7일 하기 본문

Web Development/JSP

지정된 날짜에 +7일 하기

BeOne 2008. 8. 10. 14:36

<%@ page contentType="text/html; charset=euc-kr" language="java" import="java.sql.*" errorPage="" %>
<% request.setCharacterEncoding("euc-kr"); %>
<%@ page import="java.util.*, java.text.*"%>

<%
 DecimalFormat df = new DecimalFormat("00");
 Calendar currentCalendar = Calendar.getInstance();
 
 currentCalendar.set(Calendar.YEAR, 2008);
 currentCalendar.set(Calendar.MONTH, 8-1);
 currentCalendar.set(Calendar.DATE, 10);
 
 currentCalendar.add(currentCalendar.DATE, 7);
 
 String strYear   = Integer.toString(currentCalendar.get(Calendar.YEAR));
 String strMonth  = df.format(currentCalendar.get(Calendar.MONTH) + 1);
 String strDay   = df.format(currentCalendar.get(Calendar.DATE));
 String strDate = strYear + strMonth + strDay;
 
 System.out.println("오늘 날짜 + 7일 = " + strDate);

 out.println(strDate+"<br>");
%>