Package com.fuxi.test.date;
/**
* Enter a date to calculate how many days apart from the current system date (get the system time, get the date and date, and format the SimpleDateFormat; Enter dates for similar operations)
*/
Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import java.text.ParseException;
Import Java.text.SimpleDateFormat;
Import Java.util.Calendar;
Import Java.util.Date;
public class Nowtoday {
public static void Main (string[] args) {
SimpleDateFormat Nowtime,inputtime;
BufferedReader BR;
Calendar cal= calendar.getinstance ();
String year =string.valueof (Cal.get (calendar.year)),
month = string.valueof (Cal.get (calendar.month) +1),
Day = string.valueof (Cal.get (calendar.day_of_month));
Nowtime =new SimpleDateFormat ("YyyyMMdd");
try {
String now = Year+month+day;
Date nowdate = Nowtime.parse (now);
System.out.println ("Now the date is:" +now);
System.out.println ("Please enter a date, will calculate your output date and now how many days apart");
br = new BufferedReader (new InputStreamReader (system.in));
String input = Br.readline ();
Inputtime = new SimpleDateFormat ("YyyyMMdd");
Date inputdate = inputtime.parse (input);
Long seconds = Inputdate.gettime ()-nowdate.gettime ();
int k = (int) (seconds/(1000*60*60*24));
System.out.println (k);
catch (ParseException e) {
TODO auto-generated Catch block
E.printstacktrace ();
catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
}