Save time in format: HOUR:MINUTE using primefaces

Asked

Viewed 26 times

0

I have a following problem, I want to save an entry time in which I type this time and I did this in xhtml:

<p:datePicker maxlength="6" id="timeonly" showTime="true"  value="#{gerenciadorController.gerenciador.gerenciador_horarioEntrada}" timeOnly="true" pattern="HH:mm"/>

but it only returns to me like this: 1970-01-01 00:00:00.0 how do I save only the hours??

code:

    private Date gerenciador_horarioEntrada;
    public Gerenciador( Date gerenciador_horarioEntrada) {
        this.gerenciador_horarioEntrada = gerenciador_horarioEntrada;
    }

    public Date getGerenciador_horarioEntrada() {
        return gerenciador_horarioEntrada;
    }

    public void setGerenciador_horarioEntrada(Date gerenciador_horarioEntrada) {
        this.gerenciador_horarioEntrada = gerenciador_horarioEntrada;
    }

hbm.xml code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 13/04/2016 09:29:45 by Hibernate Tools 4.3.1 -->
<hibernate-mapping>
  <!--Mapeando banco de dados-->
  <class catalog="Bravo" name="br.com.senacrs.TO.Gerenciador" optimistic-lock="version" table="tb_gerenciador">
    <id name="idGerenciador" type="java.lang.Integer">
      <column name="idGerenciador"/>
      <generator class="identity"/>
    </id>
    <property name="gerenciador_nomeFornecedor" type="string">
      <column length="60" name="gerenciador_nomeFornecedor" not-null="true"/>
    </property>
    <property name="gerenciador_placaCaminhao" type="string">
      <column length="8" name="gerenciador_placaCaminhao" not-null="true"/>
    </property>
    <property name="gerenciador_nomeMotorista" type="string">
      <column length="50" name="gerenciador_nomeMotorista" not-null="true"/>
    </property>
    <property name="gerenciador_horarioEntrada" type="java.util.Date">
      <column  name="gerenciador_horarioEntrada"  />
    </property>
  </class>
</hibernate-mapping>

sql is declared as date tbm

  • Your problem is in the database, java or datepicker?

  • I think the problem is in java, but I can not say, I researched a lot, tried some methods and did not work..

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.