View difference between Paste ID: 8g8xhVWc and R1rdftq0
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
import java.util.Date;
3
import org.joda.time.DateTime;
4
import org.joda.time.Days;
5
public class DaysBetweenTwoDates {
6
7
	public static void main(String[] args) {
8
		Scanner input = new Scanner(System.in);
9
		String startDate = input.nextLine();
10
		String endDate = input.nextLine();
11
		String[] firstDateSplitted = startDate.split("-");
12
		String[] secondDateSplitted = endDate.split("-");
13
		DateTime past = new DateTime(Integer.parseInt(firstDateSplitted[2]),
14
				Integer.parseInt(firstDateSplitted[1]),
15
				Integer.parseInt(firstDateSplitted[0]), 0,0);
16
		DateTime today = new DateTime(Integer.parseInt(secondDateSplitted[2]),
17
				Integer.parseInt(secondDateSplitted[1]),
18
				Integer.parseInt(secondDateSplitted[0]), 0,0);
19-
		int days = Days.daysBetween(new DateTime(past), new DateTime(today)).getDays();
19+
		int days = Days.daysBetween(past, today).getDays();
20
		System.out.println(days);
21
	}
22
23
}