List of usage examples for javax.persistence TemporalType DATE
TemporalType DATE
To view the source code for javax.persistence TemporalType DATE.
Click Source Link
java.sql.Date
From source file:com.p5solutions.core.jpa.orm.ConversionUtilityImpl.java
/** * Convert timestamp./*w w w. java 2 s . c o m*/ * * @param pb * the pb * @param timestamp * the timestamp * @param targetType * the target type * @return the object */ public Object convertTimestamp(ParameterBinder pb, Timestamp timestamp, Class<?> targetType) { // TODO probably needs further checking based on JPA annotations, some // timezone issues??? if (ReflectionUtility.isDate(targetType)) { // Check for Temporal if (pb != null) { Temporal temporal = pb.getTemporal(); if (temporal != null) { Date converted = timestamp; if (TemporalType.DATE.equals(temporal.value())) { java.sql.Date dt = new java.sql.Date(timestamp.getTime()); return dt; } else if (TemporalType.TIME.equals(temporal.value())) { java.sql.Time tm = new java.sql.Time(timestamp.getTime()); return tm; } else if (TemporalType.TIMESTAMP.equals(temporal.value())) { } return converted; } } Date test = new Date(timestamp.getTime()); return test; // return (Date) timestamp; } else if (ReflectionUtility.isStringClass(targetType)) { // TODO needs to be formatted based on the Format defined by the // 'custom?' // Format annotation ???? return timestamp.toLocaleString(); } else if (ReflectionUtility.isLongClass(targetType)) { } return timestamp; }
From source file:com.syncnapsis.data.model.User.java
/** * Optionale Benutzerinformation: Geburtstag * //from www .ja v a2 s . c o m * @return birthday */ @Column(nullable = true) @Temporal(TemporalType.DATE) public Date getBirthday() { return birthday; }
From source file:com.medigy.persist.model.person.Person.java
@Past @Basic(temporalType = TemporalType.DATE) @Column(name = "birth_date") public Date getBirthDate() { return birthDate; }
From source file:edu.ku.brc.specify.datamodel.Address.java
/** * @return the endDate/*from w ww. j a v a2 s.com*/ */ @Temporal(TemporalType.DATE) @Column(name = "EndDate", unique = false, nullable = true, insertable = true, updatable = true) public Calendar getEndDate() { return endDate; }
From source file:edu.ku.brc.specify.datamodel.Address.java
/** * @return the startDate/*from w ww . jav a 2 s . c o m*/ */ @Temporal(TemporalType.DATE) @Column(name = "StartDate", unique = false, nullable = true, insertable = true, updatable = true) public Calendar getStartDate() { return startDate; }
From source file:fr.amapj.service.services.meslivraisons.MesLivraisonsService.java
/** * Retourne la liste des mois de cette pages mes livraisons * @param dto//from w w w . j a v a 2 s .c om * @return */ private List<Date> getMonth(EntityManager em, Date dateDebut, Date dateFin) { // On extrait toutes les livraisons sur l'intervalle et on en dduit la liste de mois Query q = em.createQuery("select distinct(mcd.dateLiv) from ModeleContratDate mcd WHERE " + "mcd.dateLiv>=:deb AND " + "mcd.dateLiv<=:fin " + "order by mcd.dateLiv"); q.setParameter("deb", dateDebut, TemporalType.DATE); q.setParameter("fin", dateFin, TemporalType.DATE); List<Date> mcds = q.getResultList(); List<Date> res = new ArrayList<Date>(); for (Date mcd : mcds) { Date month = fr.amapj.common.DateUtils.firstDayInMonth(mcd); if (res.contains(month) == false) { res.add(month); } } return res; }
From source file:com.haulmont.cuba.gui.components.AbstractFieldFactory.java
protected Component createDateField(Datasource datasource, String property, MetaPropertyPath mpp, Element xmlDescriptor) {/* www.j a v a 2 s .c om*/ DateField dateField = componentsFactory.createComponent(DateField.class); dateField.setDatasource(datasource, property); MetaProperty metaProperty = mpp.getMetaProperty(); TemporalType tt = null; if (metaProperty != null) { if (metaProperty.getRange().asDatatype().equals(Datatypes.get(DateDatatype.NAME))) { tt = TemporalType.DATE; } else if (metaProperty.getAnnotations() != null) { tt = (TemporalType) metaProperty.getAnnotations().get("temporal"); } } final String resolution = xmlDescriptor == null ? null : xmlDescriptor.attributeValue("resolution"); String dateFormat = xmlDescriptor == null ? null : xmlDescriptor.attributeValue("dateFormat"); DateField.Resolution dateResolution = DateField.Resolution.MIN; if (!StringUtils.isEmpty(resolution)) { dateResolution = DateField.Resolution.valueOf(resolution); dateField.setResolution(dateResolution); } else if (tt == TemporalType.DATE) { dateField.setResolution(DateField.Resolution.DAY); } if (dateFormat == null) { if (dateResolution == DateField.Resolution.DAY) { dateFormat = "msg://dateFormat"; } else if (dateResolution == DateField.Resolution.MIN) { dateFormat = "msg://dateTimeFormat"; } } Messages messages = AppBeans.get(Messages.NAME); if (!StringUtils.isEmpty(dateFormat)) { if (dateFormat.startsWith("msg://")) { dateFormat = messages.getMainMessage(dateFormat.substring(6, dateFormat.length())); } dateField.setDateFormat(dateFormat); } else { String formatStr; if (tt == TemporalType.DATE) { formatStr = messages.getMainMessage("dateFormat"); } else { formatStr = messages.getMainMessage("dateTimeFormat"); } dateField.setDateFormat(formatStr); } return dateField; }
From source file:com.hive.enterprisemanage.entity.EEnterpriseinfo.java
@Temporal(TemporalType.DATE) @Column(name = "DBUSINESSLICENSEEND", nullable = true, length = 7) @JsonSerialize(using = JsonDateSerializer.class) public Date getDbusinesslicenseend() { return this.dbusinesslicenseend; }
From source file:fr.amapj.service.services.meslivraisons.MesLivraisonsService.java
/** * Indique si il y a au moins une livraison cette semaine * @param dto//from ww w . j a v a 2 s . c o m * @return */ private boolean hasLivraison(EntityManager em, Date dateDebut, Date dateFin) { // On extrait toutes les livraisons sur l'intervalle Query q = em.createQuery("select count(mcd.dateLiv) from ModeleContratDate mcd WHERE " + "mcd.dateLiv>=:deb AND " + "mcd.dateLiv<=:fin "); q.setParameter("deb", dateDebut, TemporalType.DATE); q.setParameter("fin", dateFin, TemporalType.DATE); return LongUtils.toInt(q.getSingleResult()) > 0; }
From source file:com.hive.enterprisemanage.entity.EEnterpriseinfo.java
@Temporal(TemporalType.DATE) @Column(name = "DAPPROVE", nullable = true, length = 7) @JsonSerialize(using = JsonDateTimeSerializer.class) public Date getDapprove() { return this.dapprove; }