0 Replies Latest reply on Mar 29, 2009 3:38 AM by nschweig

    CustomConverter problem with time

    nschweig

      Hi,

      I tried to write a general custom date and time-converter because I do not want to write the whole formatting information everytime in the tag like this:

      <f:convertDateTime pattern="HH:mm" timeZone="Europe/Berlin"/>


      The problem is to format the time; the date works. Heres my code:

      public class CMTDateTimeConverter extends DateTimeConverter {
       public static final String CONVERTER_ID = "CMTDTConverter";
      
       final public static String DATE_FORMAT = "dd-MMM-yyyy";
       final public static String TIME_FORMAT = "HH:mm";
      
       public CMTDateTimeConverter() {
       super();
      
       //setLocale(getLocale());
       setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
       setTimeStyle(DATE_FORMAT);
       setDateStyle(TIME_FORMAT);
       }
      }


      in faces-config:
      <converter>
       <description>Timezone Europe/Berlin</description>
       <converter-id>CMTDTConverter</converter-id>
       <converter-class>de.cmt.helper.CMTDateTimeConverter</converter-class>
       </converter>


      I try to display the time as following:
      <h:outputText value="#{appointment.time}" >
       <f:convertDateTime converterId="CMTDTConverter"/>
      </h:outputText>

      The time is always displayed as 01.01.1970.

      Can anyone please help me? Thank you
      NSchweig