#### Java program to find out the number of days elapsed between two dates.

Java program to find out the difference between two dates given as DD-MM-YY.

import java.io.*; class datedif { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter the first date:"); System.out.print("enter the days="); int d1=Integer.parseInt(br.readLine()); System.out.print("enter the month="); int m1=Integer.parseInt(br.readLine()); System.out.print("enter the year="); int y1=Integer.parseInt(br.readLine()); System.out.println("enter the second date coming after the first date:"); System.out.print("enter the days="); int d2=Integer.parseInt(br.readLine()); System.out.print("enter the month="); int m2=Integer.parseInt(br.readLine()); System.out.print("enter the year="); int y2=Integer.parseInt(br.readLine()); int c,i,j,t=0; int a[]={31,29,31,30,31,30,31,31,30,31,30,31}; int b[]={31,28,31,30,31,30,31,31,30,31,30,31}; c=y2-y1; for(i=0;i<c;i++) { for(j=m2-1;j>=0;j--) { if(y2%4==0) t+=a[j]; else t+=b[j]; } m2=12; } for(i=m2-1;i>=m1;i--) { if(y1%4==0) t+=a[i]; else t+=b[i]; } t+=(d2-d1); System.out.println("number of days elapsed between two dates="+t); } }

#### OUTPUT:

Tags: program to find out the difference between two dates in java / bluej / c.

nice program