We have dates in the program as strings. We first parse them into dates and then find the difference between them in milliseconds. Later we convert the millisecond to DAYS and display the results as output.

import java.util.Date; import java.text.SimpleDateFormat; class Main { public static void main(String args[]) { SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); String start_date = "01 01 2019"; String end_date = "03 04 2019"; try { Date date_Before = myFormat.parse(start_date); Date date_After = myFormat.parse(end_date); long date_difference = date_After.getTime() - date_Before.getTime(); float final_days = (date_difference / (1000*60*60*24)); System.out.println("Number of Days between Two dates are: "+final_days); } catch (Exception e) { e.printStackTrace(); } } }

Output:-