Programing/JSP 예제

간단한 현재 날짜 뽑기

Dongkkase 2008. 12. 27. 21:05
반응형

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    
<html>
<head>
	<title>간단한 현재시간 표시</title>
</head>
<body>
	<%@ page import="java.util.Date"%>
	<%@ page import="java.text.SimpleDateFormat"%>
	
	<%
	Date nowDate=new Date();		
		//└현재날짜와 시간을 얻어온다.
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy년MM월dd일");
		//└날짜형식을 yyyy년MM월dd일 형식으로 사용하기 위해서 simpledateformat 객체 생성
	String formatDate=dateFormat.format(nowDate);
		//└현재의 날짜와 시간에 yyyy년MM월dd일 형식을 format()메소드를 사용해서 적용
	
	out.println(formatDate);
	%>
</body>
</html>
반응형