2014-03-19 31 views
1

我已經將日期存儲在我的數據庫中(而不是幾個月)。我想從特定月份獲取記錄。是否可以在hibernate3中爲此寫入標準?從hibernate3獲取月份的標準

+0

請給我更多的信息。 – Radan

+0

請檢查這是否是你想要的http://stackoverflow.com/questions/17233900/how-to-dynamically-search-between-two-dates-in-hql – Radan

回答

0

你可以這樣

日期的startDate寫= 2014年3月1日

日期結束日期= 2014-03-31

標準標準=的getSession()個createCriteria(getDomainClass()) ; criteria.add(Restrictions.between(「date」,startDate,endDate));

(OR)

如果你的日期格式爲 「YYYY-MM-DD」

字符串日期= 「2014-03」;

Criteria criteria = getSession()。createCriteria(getDomainClass());

criteria.add(Restrictions.like(「date」,date));