Example usage for javax.persistence TemporalType DATE

List of usage examples for javax.persistence TemporalType DATE

Introduction

In this page you can find the example usage for javax.persistence TemporalType DATE.

Prototype

TemporalType DATE

To view the source code for javax.persistence TemporalType DATE.

Click Source Link

Document

Map as java.sql.Date

Usage

From source file:sf.wicketlearningapplication.domain.Bug.java

@Temporal(TemporalType.DATE)
public Date getDueByDate() {
    if (dueByDate != null) {
        return new Date(dueByDate.getTime());
    } else {//  w w w  .j  ava2s .c o  m
        return null;
    }
}

From source file:com.bedatadriven.rebar.persistence.mapping.DateMapping.java

@Override
protected SqliteTypes getSqlTypeName() {
    if (type == TemporalType.DATE) {
        // store dates as LocalDates without timezone
        // see http://www.sqlite.org/lang_datefunc.html
        return SqliteTypes.text;
    } else {//from  w  w  w. j av a  2 s.  c  o m
        // otherwise we store as posix time 
        return SqliteTypes.real;
    }
}

From source file:com.haulmont.cuba.gui.components.filter.condition.FilterConditionUtils.java

public static String formatParamValue(Param param, Object value) {
    //noinspection unchecked
    Datatype datatype = Datatypes.get(param.getJavaClass());
    MetaProperty property = param.getProperty();
    if (property != null) {
        TemporalType tt = (TemporalType) property.getAnnotations().get(MetadataTools.TEMPORAL_ANN_NAME);
        if (tt == TemporalType.DATE) {
            datatype = Datatypes.getNN(java.sql.Date.class);
        }/*from w  w  w  .  j a  v  a 2  s  .co  m*/
    }
    if (datatype != null) {
        UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class);
        return datatype.format(value, userSessionSource.getLocale());
    }
    return value.toString();
}

From source file:org.mitre.openid.connect.repository.impl.JpaEventRepository.java

@SuppressWarnings("unchecked")
@Override//from   www  .j  a  va 2  s .c o  m
@Transactional
public Collection<Event> getEventsDuringPeriod(Date start, Date end, int startChunk, int chunkSize) {

    Query query = manager.createQuery("SELECT e FROM Event e WHERE e.timestamp BETWEEN :start AND :end");

    query = query.setParameter("start", start, TemporalType.DATE);
    query = query.setParameter("end", end, TemporalType.DATE);
    query = query.setFirstResult(startChunk);
    query = query.setMaxResults(chunkSize);

    return query.getResultList();
}

From source file:at.irian.demo.jsfatwork.repository.jpa.JpaPollRepository.java

public List<Poll> loadOpenPolls(User user) {
    Query openPolls = this.entityManager.createNamedQuery(FIND_OPEN_POLLS);
    openPolls.setParameter(PARAMETER_CURRENT_DATE, new Date(), TemporalType.DATE);
    openPolls.setParameter(PARAMETER_USER, user);

    return openPolls.getResultList();
}

From source file:org.parancoe.basicWebApp.po.Person.java

@Temporal(TemporalType.DATE)
@NotNull
@Past
public Date getBirthDate() {
    return birthDate;
}

From source file:io.github.davejoyce.dao.composite.model.AppUser.java

@Temporal(TemporalType.DATE)
@Column(name = "CREATED_DT", nullable = false, insertable = true, updatable = false)
public Date getCreateDate() {
    return createdDate;
}

From source file:com.bedatadriven.rebar.persistence.mapping.DateMapping.java

@Override
public void writeColumnValues(JSONStringer writer, Object entity) throws JSONException {
    Date value = (Date) getValue(entity);
    if (value == null) {
        writer.value(null);//from   w w w.j  a  va 2  s .co  m
    } else {
        if (type == TemporalType.DATE) {
            writer.value(ISO_8601_FORMAT.format(value));
        } else {
            writer.value(value.getTime());
        }
    }
}

From source file:org.lightadmin.core.persistence.metamodel.PersistentPropertyType.java

private static boolean isOfDateType(PersistentProperty persistentProperty) {
    Class<?> attrType = persistentProperty.getType();

    if (java.sql.Date.class.equals(attrType)) {
        return true;
    }//from   w w  w  .ja  va2  s  . com

    if (LocalDate.class.equals(attrType)) {
        return true;
    }

    if (Date.class.equals(attrType) || Calendar.class.equals(attrType)) {
        return hasTemporalType(persistentProperty, TemporalType.DATE);
    }

    return false;
}

From source file:com.jasperreports.hrdb.Employee.java

@Temporal(TemporalType.DATE)
@Column(name = "`BIRTHDATE`", nullable = true)
public Date getBirthdate() {
    return this.birthdate;
}