傳入一個開始時間(beginDate)以及結束時間(endDate)與某個時間(someTime)進行比較:
restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(root.<Date> get("someTime"), beginDate));
restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(root.<Date> get("someTime"), endDate));
其實就是兩個方法不一樣:大於用greaterThanOrEqualTo(...)和小於用lessThanOrEqualTo(...)