[opencms-dev] how to format dates

Bernat López bernatl at adequa.net
Tue Sep 5 15:27:56 CEST 2006


Hi I?igo,

Will be a good idea to have a taglib with an entry to do this format 
conversions in a taglib based templates, or to have a JSP to do this with an 
include, as follows:

DateTemplate (showdate.jsp)
<%@page buffer="none" session="false" import="org.opencms.file.*, 
org.opencms.jsp.*, java.util.*, java.text.*" %>

<%
  Map params=request.getParameterMap();


  if(params != null)
  {
    String[] s_Data=(String[])params.get("data");
    long l_data=(s_Data!=null?Long.parseLong(s_Data[0]):0L);

    if(l_data != 0)
    {
      Date data=new Date(l_data);

      SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
      out.print(sdf.format(data));
    }
  }
%>

And on your template do something similir this:

<cms:contentcheck ifexists="Data_Publicacio">
<cms:include file="/ca/showDate.jsp">
    <cms:param name="data">
        <cms:contentshow element="Data_Publicacio" />
    </cms:param>
</cms:include>
</cms:contentcheck>

Regards,

Bernat López
Adequa Software
http://www.adequa.net/esp

----- Original Message ----- 
From: "Shi Yusen" <shiys at langhua.cn>
To: "'The OpenCms mailing list'" <opencms-dev at opencms.org>
Sent: Tuesday, September 05, 2006 2:40 PM
Subject: Re: [opencms-dev] how to format dates


Hi Inigo,

SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy");
String dateString = dateFormat.format(new Date(1157448300000L));

Regards,

Shi Yusen/Beijing Langhua Ltd.
--------------------------------------------------------------
Tel: 86-10-88514088, 88514099
Fax: 86-10-88514099
Email: shiys at langhua.cn
Website: http://www.langhua.cn/
--------------------------------------------------------------


-----邮件原件-----
发件人: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.
org] 代表 Inigo
发送时间: 2006年9月5日 18:23
收件人: opencms-dev at opencms.org
主题: [opencms-dev] how to format dates

Hello:
    I am trying to show some linklists in a web page. Everything works
fine using the contentloop and the contentshow opencms tags, except for
the fact that the dates are shown wrong. Instead of showing 09/05/06,
OpenCMS shows 1157448300000.

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev


_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev





More information about the opencms-dev mailing list