丰富的日历日期格式
我使用 rich:calendar 和特定模式 datePattern="dd/MM/yyyy"
。当我尝试从日历中获取字符串值并使用 SimpleDateFormat ("dd/MM/yyyy")
解析它时,我遇到了一些问题,我发现变量中的日期格式不是我所期望的: Tue Nov 22 00:00:00 EET 2011
以下是一些代码:
丰富:日历
<rich:calendar value="#{validateReportAction.selectedDate}"
required="true"
requiredMessage="You must select a date"
mode="ajax"
id="date"
datePattern="dd/MM/yyyy"/>
在豆子
DateFormat formatter;
Date date;
formatter = new SimpleDateFormat("dd/MM/yyyy");
date = (Date) formatter.parse(getSelectedDate());
,其中 getSelectedDate()
返回 Tue Nov 22 00:00:00 EET 2011
但我只想要日/月/年。我怎样才能做到这一点?
I use rich:calendar with a specific pattern datePattern="dd/MM/yyyy"
. When I tried to get the string value from the calendar and parse it using SimpleDateFormat ("dd/MM/yyyy")
I had some issues and I saw the date format in my variable is not what I expected: Tue Nov 22 00:00:00 EET 2011
Here is some code:
rich:calendar
<rich:calendar value="#{validateReportAction.selectedDate}"
required="true"
requiredMessage="You must select a date"
mode="ajax"
id="date"
datePattern="dd/MM/yyyy"/>
in bean
DateFormat formatter;
Date date;
formatter = new SimpleDateFormat("dd/MM/yyyy");
date = (Date) formatter.parse(getSelectedDate());
where getSelectedDate()
returns Tue Nov 22 00:00:00 EET 2011
but I want only the day/month/year. How can I achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我可以正常工作的代码;
Here is the code that i have that works properly;
将此属性添加到您的标签中,看看它是否解决了问题:
问候!
Add this attribute inside your tag and see if it fixes the issue:
Regards!