Panadol Chong Panadol Chong - 1 month ago 14
Java Question

How to display date format in other country pattern

Good day,

I have a jsp code as follow:

<fmt:formatDate value="<%= new java.util.Date() %>" pattern="EEEE, dd/MM/yyyy HH:mm:ss" />


Where by the
fmt
tag is refering to

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>


from
com.ibm.ws.webcontainer.jar
.

So the date display in browser will be:
Monday, 07/11/2016 11:04:15


I would like to ask, any way for me to display this day in other country language? For example, in Malaysia, so it will be like:
Isnin, 07/11/2016 11:04:15
.

Additional question, is the
Monday
generate from the
com.ibm.ws.webcontainer.jar
? Because I search for my whole workspace, but didnt see any
Monday
in coding.

Kindly advise.

Answer

I would just change the scope to session as below

Date in France:

<fmt:setLocale value="fr_FR" scope="session"/>
<fmt:formatDate value="${now}" dateStyle="full"/> <br/>

Date in US:

<fmt:setLocale value="en_US" scope="session"/>
<fmt:formatDate value="${now}" dateStyle="full" /> <br/>