Code example for TreeSet

Methods: add, contains

0
        newDate = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).parse(date);
        add(newDate);
    } 
     
    public void add(Date date) {
        if (!validity.contains(date)) {
            validity.add(date);
        } 
    } 
     
    public TreeSet<Date> getValidity() {
        return validity;
    } 
     
     
}