5 Replies Latest reply on May 26, 2010 12:30 PM by Ronan Forker

    Datatable + date problem

    Ronan Forker Newbie



      I have a problem where the richfaces datatable displaying a date does not appear to display the correct date (it is out by one day).


      The long (date) in the basic sample i've created below is a date I have stored in a database.


      Test Bean:

      public class TestBean {
           private List<Date> dateList;
           public TestBean() {
                dateList = new ArrayList<Date>();
                Date d = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy");
           public List<Date> getDateList() {
                return dateList;
           public void setDateList(List<Date> dateList) {
                this.dateList = dateList;


      Test JSF:

      <rich:dataTable id="docListDataTable" value="#{TestBean.dateList}" var="date" width="100%" columns="1" columnsWidth="100%">
           <rich:column id="c4" title="Date">
                <f:facet name="header">
                     <h:outputText id="h4" value="Date"/>
                <h:outputText id="o4" value="#{date}"/>

      The output of the above will be a table like this:





      However the same date which is displayed in the table as 24-May-2010 is outputted to the console as 25-May-2010. You can also perform a .toString() on the date object in the example and it too will print the 25-May-2010.


      This inconsistency has caused me a lot of problems because the last place a looked was the rendering of the date object. Am I doing something wrong or is this a bug?