使用hibernate查询获取日期范围内的每一天

使用hibernate查询获取日期范围内的每一天,hibernate,Hibernate,您如何获得2014年1月1日至2014年2月5日期间每周一、周四和周五的日期 如果hibernate查询无法实现,有什么解决建议吗 提前谢谢 我不清楚您为什么要使用查询来获取这些信息,除非您的问题还有更多 假设您使用的是Java,我可能会使用Joda库来实现这一点 比如: LocalDate currentDate = new LocalDate(2014, 1, 1); LocalDate endDate = new LocalDate(2014, 2, 5); while(currentD

您如何获得2014年1月1日至2014年2月5日期间每周一、周四和周五的日期

如果hibernate查询无法实现,有什么解决建议吗


提前谢谢

我不清楚您为什么要使用查询来获取这些信息,除非您的问题还有更多

假设您使用的是Java,我可能会使用Joda库来实现这一点

比如:

LocalDate currentDate = new LocalDate(2014, 1, 1);
LocalDate endDate = new LocalDate(2014, 2, 5);

while(currentDate.isBefore(endDate)) {

  if (currentDate.getDayOfWeek() == 1 || currentDate.getDayOfWeek() == 4 ||     currentDate.getDayOfWeek() == 5) {
    System.out.println(currentDate.toString());
  }
  currentDate = currentDate.plusDays(1);
}

谢谢亚历克斯!我在想,如果有10万条记录被取出并在内存中处理,会有什么问题吗?你只需要做一次,因为答案不会改变。