Advertisement
Guest User

Lambdas filtro

a guest
Jan 20th, 2016
297
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class User {
  2.     private String name;
  3.     privateCalendar birthDate;
  4.     private String address;
  5.     private String phone;
  6.     private String email;
  7.  
  8.         // constructores getters y setters
  9. }
  10.  
  11. Calendar after = Calendar.getInstance();
  12. after.setTime(fmt.parse("01-01-1990"));
  13. Calendar before = Calendar.getInstance();
  14. before.setTime(fmt.parse("31-12-1992"));
  15.  
  16. List<User> filtered = users.stream().filter(u ->
  17.                     u.birthDate.after(after) && u.birthDate.before(before))
  18.                     .collect(Collectors.toList());
Advertisement
RAW Paste Data Copied
Advertisement