How to get midnight of given date?
date, java
Solution
Use JodaTime as such:
public List<Game> getGamesByDate(Date day) throws SQLException {
final DateTime startDate = new DateTime(day).withTimeAtStartOfDay();
....
}
Problem
I need to know how to get current midnight from date. For example I get "15.06.2012 16:40:20" and i need "15.06.2012 00:00:00". ``` public List<Game> getGamesByDate(Date day) throws SQLException { final Date startDate = day; //here I need to convert startDate to midnight somehow final Date endDate = new Date(day.getTime() + (23 * HOUR) + (59 * MINUTE)); final List<Game> games = gameDAO.getGamesByDate(startDate, endDate); return games; } ```