I am using Liferay 6.2 and want to use a liferay-ui:input-date field. Field itself is working fine. However i want to change the displayed date Format from
mm/dd/yyyy
to
dd.mm.yyyy
But how to do this? I cant see any attibutes to set this...
<liferay-ui:input-date firstDayOfWeek="1"
yearValue="<%=calendar.get(calendar.YEAR)%>"
monthValue="<%=calendar.get(calendar.MONTH)%>"
dayValue="<%=calendar.get(calendar.DAY_OF_MONTH)%>" dayParam="dateFrom-day"
monthParam="dateFrom-month" yearParam="dateFrom-year" />
I looked at the input-date taglib code and if you want to change the pattern you have to modify its code. Path to the file: \webapps\ROOT\html\taglib\ui\input_date\page.jsp. Simply you can replace this line:
Format format = FastDateFormatFactoryUtil.getSimpleDateFormat(simpleDateFormatPattern, locale);
with:
Format format = FastDateFormatFactoryUtil.getSimpleDateFormat("dd.MM.yyyy", locale);
mask = "%d.%m.%Y";
and save the file. More elegant solution would be creating a hook on this component, but it's up to you.
AFAIK this tag displays the date according to the user's language choice. By default that's en_US
, thus mm/dd/yyyy. If you set your user's default language (or your portal's) to en_GB
(or de
, for example), the format will be according to the language that's used on the UI.
来源:https://stackoverflow.com/questions/45671323/liferay-input-date-format