java나 jsp파일에서 날짜를 형식대로 출력하는 소스입니다.


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">

<head>

<title>TIME</title>

</head>

<body>

<%

Date now = new Date();

%>

<%=now %><br>

<%

SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");

String today = sf.format(now);

%>

<%=today %><br>

<%

sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

today = sf.format(now);

%>

<%=today %><br>

<%

sf = new SimpleDateFormat("yyyy년MM월dd일 E요일 a hh:mm:ss");

today = sf.format(now);

%>

<%=today %><br>

</body>

</html>

+ Recent posts