77import java .util .ArrayList ;
88import java .util .List ;
99import java .util .Optional ;
10+ import java .time .temporal .ChronoUnit ;
1011
1112import javafx .collections .FXCollections ;
1213import javafx .event .EventHandler ;
@@ -31,7 +32,7 @@ public class MainScreenController {
3132 @ FXML private GridPane calendarGrid ;
3233 @ FXML private ListView <AssignmentProvider > accountList ;
3334 @ FXML private Label scheduleDescriptionLabel ;
34- @ FXML private ListView <String > scheduleList ;
35+ @ FXML private ListView <Assignment > scheduleList ;
3536 @ FXML Spinner <Integer > scheduleDays ;
3637 private int currentSelectionY = -1 ;
3738 private int currentSelectionX = -1 ;
@@ -82,7 +83,7 @@ public void handle(MouseEvent event) {
8283 LocalDate selectedDate = (LocalDate ) sender .getProperties ().get ("date" );
8384 LocalDate today = LocalDate .now ();
8485 LocalDate endOfSchedule = today .plusDays (schedule .size () - 1 );
85- List <String > assignments = new ArrayList <>();
86+ List <Assignment > assignments = new ArrayList <>();
8687 if (today .isAfter (selectedDate )) {
8788 scheduleList .setItems (FXCollections .observableArrayList (assignments ));
8889 return ;
@@ -91,18 +92,10 @@ public void handle(MouseEvent event) {
9192 scheduleList .setItems (FXCollections .observableArrayList (assignments ));
9293 return ;
9394 }
94- public void differenceCalculator () throws ParseException {
95- SimpleDateFormat sdf = new SimpleDateFormat ("MM/dd/yyyy" , Locale .ENGLISH );
96- Date firstDate = sdf .parse (today );
97- Date secondDate = sdf .parse (selectedDate );
98- long diffInMillies = Math .abs (secondDate .getTime () - firstDate .getTime ());
99- long diff = TimeUnit .DAYS .convert (diffInMillies , TimeUnit .MILLISECONDS );
100-
101- assertEquals (6 , diff );
102- }
103- for (String assigns : assignments ) {
104- listView .setItems (FXCollections .observableArrayList ("assigns" , diff ));
105- }
95+
96+ long daysBetween = java .time .temporal .ChronoUnit .DAYS .between (today ,selectedDate );
97+ List <Assignment > scheduleFactors = schedule .get ((int ) daysBetween );
98+ scheduleList .setItems (FXCollections .observableArrayList (scheduleFactors ));
10699 }
107100 };
108101 label .addEventHandler (MouseEvent .MOUSE_CLICKED , handler );
0 commit comments