public static long dValue(String start,String end) { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); long t=0; try{ Date dstart = sf.parse(start); Date dend = sf.parse(end); Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); int month = c1.get(Calendar.MONTH); c1.setTime(dstart); c2.setTime(dend); int syear = c1.get(Calendar.YEAR); int smonth = c1.get(Calendar.MONTH)+1; int sday = c1.get(Calendar.DATE); int eyear = c2.get(Calendar.YEAR); int emonth = c2.get(Calendar.MONTH)+1; int eday = c2.get(Calendar.DATE); c1.set(syear,smonth,sday); c2.set(eyear,emonth,eday); t = (c2.getTimeInMillis()-c1.getTimeInMillis())/(1000*60*60*24); }catch (ParseException e){ } return t+1; }