If statement checking if current date equals string date <p>trying to retrieve users from an ArrayList that string bookingdate equals the current date. my problem is I don't believe I am formatting my if statement correctly. the returned users will then be displayed on a datatable in a xhtml file.</p> <pre><code> public ArrayList&lt;User&gt; getDinner() throws ParseException { Date today = new Date(); DateFormat formatter; Date date; formatter = new SimpleDateFormat("dd/MM/yy"); date = formatter.parse(bookingdate); ArrayList&lt;User&gt; subset = new ArrayList&lt;User&gt;(); for (User user : userList) { if (((today.equals(date))) &amp;&amp; (1700 &lt; user.bookingtime)) { subset.add(user); } } return subset; } </code></pre> <p>above is where I am having the problem below is the rest of the file.</p> <pre><code>import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date; import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date; import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date; import java.io.Serializable; import java.sql.Time; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.event.ValueChangeEvent; @ManagedBean(name = "user") @SessionScoped public class UserData implements Serializable {private static final long serialVersionUID = 1L; private String name; private String last; private String email; private String phone; private String size; Integer bookingtime; String bookingdate; private String requirements; private String table; private String userName; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getSize() { return size; } public void setSize(String size) { this.size = size; } public Integer getBookingtime() { return bookingtime; } public void setBookingtime(Integer bookingtime) { this.bookingtime = bookingtime; } public String getBookingdate() { return bookingdate; } public void setBookingdate(String bookingdate) { this.bookingdate = bookingdate; } public String getRequirements() { return requirements; } public void setRequirements(String requirements) { this.requirements = requirements; } public void settable(String table) { this.table = table; } public String gettable() { return table; } private static final ArrayList&lt;User&gt; userList = new ArrayList&lt;User&gt;(Arrays.asList( new User("Janet", "Harris", "Janet12@hotmail.co.uk", "07714662361", "3", 1910, "12/05/2015", "Flowers", null), new User("Amy", "Harris", "Amy1234@hotmail.co.uk", "07714662361", "4", 1930, "05/03/2015", "Vegan", null), new User("Louise", "Hardbattle", "LouiseHardbattlex@hotmail.co.uk", "01512242901", "6", 1600, "13/05/2015", "Friends birthday", null), new User("Mark", "Jenkins", "MarkJ2013@live.co.uk", "07866406591", "2", 1900, "13/05/2015", "N/A", null), new User("Peter", "Lunn", "Plunn@hotmail.com", "01514422398", "2", 1930, "13/05/2015", "First time here", null), new User("Lee", "Allen", "leeallen1212@hotmail.co.uk", "07861106591", "2", 1945, "13/05/2015", "N/A", null), new User("Jess", "Maloney", "Jess2015maloney@live.com", "07713980273", "5", 1300, "14/05/2015", "18th birthday party - please provide balloons", null), new User("Christian", "Riley", "Riley1980@hotmail.com", "01514442938", "4", 1400, "14/05/2015", "N/A", null), new User("Carl", "Lunt", "CarlL101@live.com", "07844408012", "2", 1430, "14/05/2015", "N/A", null), new User("Peter", "Moore", "PeterM@hotmail.com", "01512324289", "2", 1830, "14/05/2015", "Anniversary", null ))); public ArrayList&lt;User&gt; getCustomers() { return userList; } public ArrayList&lt;User&gt; getDinner() { DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); ArrayList&lt;User&gt; subset = new ArrayList&lt;User&gt;(); for (User user : userList) { if (( user.bookingdate.equals(df) ) &amp;&amp;(1700 &lt; user.bookingtime)) { subset.add(user); } } return subset; } public ArrayList&lt;User&gt; getLunch() { ArrayList&lt;User&gt; subset = new ArrayList&lt;User&gt;(); for (User user : userList) { if (1700 &gt; user.bookingtime) { subset.add(user); } } return subset; } public ArrayList&lt;User&gt; getSearch() { ArrayList&lt;User&gt; subset = new ArrayList&lt;User&gt;(); for (User user : userList) { if (userName.equals(user.bookingdate) || user.bookingdate == null) { subset.add(user); } } return subset; } public String saveAction() { //get all existing value but set "editable" to false for (User user : userList) { user.setEditable(false); } //return to current page return null; } public String editAction(User user) { user.setEditable(true); return null; } public String deleteAction(User user) { userList.remove(user); return null; } public String addAction() { User user = new User(this.name, this.last, this.email, this.phone, this.size, this.bookingtime, this.bookingdate, this.requirements, null); userList.add(user); return null; } </code></pre>