简体   繁体   中英

Parse Date to compare in JPQL query

I would like to parse an input date in java, and then use it in a query as a condition in a select in oracle database.

 String date = "2013.11.05";
    Date checkDate = new SimpleDateFormat("yyyy.MM.dd").parse(date);

    String  qString = 
    "SELECT DISTINCT T " +
    "FROM T5PFArfolyamArch T " +
    "WHERE T.arfTipus = :vcRateKod AND T.arfErvkezd = :checkDate AND T.araValid IN ('I','M')";

Query query = entityManager.createQuery(qString);
query.setParameter("vcRateKod", tipus);
query.setParameter("checkDate", checkDate);

But it gives 0 result, like the date is not equal or right format to select anything.

尝试这个

query.setParameter("checkDate", checkDate, TemporalType.DATE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM