전자정부표준프레임워크

JSTL 날짜에 요일 출력하기

yeon.Biju 2021. 11. 30. 20:44

JSTL 날짜에 요일 같이 출력하기

 

JSTL 날짜에 아래와 같은 패턴으로 요일을 출력해보고자 한다.

2021-12-01(화)

 

yyyy-MM-dd(E) 에서 (E) 가 요일을 출력해주는 것으로 보인다.

1
2
3
4
5
<!-- today  -->
<c:set var="today" value="<%=new java.util.Date()%>" />
<c:set var="todayStr"><fmt:formatDate value="${today}" pattern="yyyy-MM-dd(E)" /></c:set>
<c:out value="${todayStr}" />
<!-- //today  -->
cs

 

 

pattern attribute 는 아래와 같다.

 

 

아마도 로케일에 따라서 Tuesday 같은 경우에는 로 나오는 것 같다.

 

Code Purpose Sample
G The era designator AD
y The year 2002
M The month April & 04
d The day of the month 20
h The hour(12-hour time) 12
H The hour(24-hour time) 0
m The minute 45
s The second 52
S The millisecond 970
E The day of the week Tuesday
D The day of the year 180
F The day of the week in the month 2 (2nd Wed in month)
w The week in the year 27
W The week in the month 2
a The a.m./p.m. indicator PM
k The hour(12-hour time) 24
K The hour(24-hour time) 0
z The time zone Central Standard Time
'   The escape for text
''   The single quote

 

아래 URL에서 가져온 내용이다.

https://www.tutorialspoint.com/jsp/jstl_format_formatdate_tag.htm

 

 

JSTL - Core <fmt:formatDate> Tag

JSTL - Core Tag The tag is used to format dates in a variety of ways. Attribute The tag has the following attributes − Attribute Description Required Default Value Date value to display Yes None type DATE, TIME, or BOTH No date dateStyle FULL, LONG, MEDI

www.tutorialspoint.com