Advertisement
Guest User

Untitled

a guest
May 14th, 2014
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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(past, today).getDays();
  20.         System.out.println(days);
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement