Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Date;
- import org.joda.time.DateTime;
- import org.joda.time.Days;
- public class _07_DaysBetweenTwoDates {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String startDate = input.nextLine();
- String endDate = input.nextLine();
- String[] firstDate = startDate.split("-");
- String[] secondDate = endDate.split("-");
- DateTime first = new DateTime(Integer.parseInt(firstDate[2]),
- Integer.parseInt(firstDate[1]), Integer.parseInt(firstDate[0]), 0,0);
- DateTime second = new DateTime(Integer.parseInt(secondDate[2]),
- Integer.parseInt(secondDate[1]), Integer.parseInt(secondDate[0]), 0,0);
- int days = Days.daysBetween(first, second).getDays();
- System.out.println(days);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment