日期:2014-05-20 浏览次数:20722 次
import java.util.Calendar; import java.util.GregorianCalendar; public class Test { public static void main(String[] args) { if(args!=null && args.length==2) { String dateArray1[] = args[0].split(","); String dateArray2[] = args[1].split(","); Calendar calendar2 = new GregorianCalendar(); Calendar calendar1 = new GregorianCalendar(); calendar1.set(Integer.parseInt(dateArray1[0]), Integer.parseInt(dateArray1[1]), Integer.parseInt(dateArray1[2])); long time1=calendar1.getTimeInMillis(); calendar2.set(Integer.parseInt(dateArray2[0]), Integer.parseInt(dateArray2[1]), Integer.parseInt(dateArray2[2])); long time2=calendar2.getTimeInMillis(); long day=(time2-time1)/(1000*60*60*24); System.out.println("相隔天数:" + day); } } }