Here you can find the source of getDayCount(String yyyy_mm_dd_1, String yyyy_mm_dd_2)
public static int getDayCount(String yyyy_mm_dd_1, String yyyy_mm_dd_2) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static int getDayCount(String yyyy_mm_dd_1, String yyyy_mm_dd_2) throws ParseException { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); Date date = myFormatter.parse(yyyy_mm_dd_1); Date mydate = myFormatter.parse(yyyy_mm_dd_2); return (int) ((date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000)); }//from ww w. ja v a2 s . c o m }