Liferay input-date format

99封情书 提交于 2019-11-28 11:39:48

问题


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" />

回答1:


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.




回答2:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!