-2

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.

Panadol Chong
  • 1,793
  • 13
  • 54
  • 119
  • This tag library is called the JSTL. It relies on standard Java classes (DateFormat, SimpleDateFormat), and does of course support multiple locales. Google for "JSTL tutorial" or "JSTL documentation". I would also recommend to avoid using scriptlets by all means. Read http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files – JB Nizet Nov 07 '16 at 07:25

1 Answers1

1

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/>
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
Albin
  • 1,929
  • 2
  • 14
  • 18