public Map<Date, List<Order>> getOrdersByDate() { List<Order> orders = storage.getOrders(); Map<Date, List<Order>> result = new HashMap<Date, List<Order>>(); for (Order order : orders) { if (result.containsKey(order.getPurchaseDate())) { result.get(order.getPurchaseDate()).add(order); } else { List<Order> t = new ArrayList<Order>(); t.add(order); result.put(order.getPurchaseDate(), t); } } return result; }
public List<Order> getOlderThanDate(Date date) { List<Order> orders = storage.getOrders(); List<Order> result = new ArrayList<Order>(); for (Order order : orders) { if (order.getPurchaseDate().after(date)) { result.add(order); } } return result; }