Here you can find the source of getDaysBetween(Map
public static int getDaysBetween(Map<String, Object> params)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static int getDaysBetween(Map<String, Object> params) { String start = params.get("start_date").toString(); String end = params.get("end_date").toString(); Calendar startCalendar = Calendar.getInstance(); Calendar endCalendar = Calendar.getInstance(); Date startDate = null;//from w w w. j a v a 2s . c om Date endDate = null; try { startDate = new SimpleDateFormat("yy-MM-dd").parse(start); startCalendar.setTime(startDate); endDate = new SimpleDateFormat("yy-MM-dd").parse(end); endCalendar.setTime(endDate); } catch (ParseException e) { } int days = endCalendar.get(Calendar.DAY_OF_YEAR) - startCalendar.get(Calendar.DAY_OF_YEAR); int y2 = endCalendar.get(Calendar.YEAR); if (startCalendar.get(Calendar.YEAR) != y2) { startCalendar = (Calendar) startCalendar.clone(); do { days += startCalendar.getActualMaximum(Calendar.DAY_OF_YEAR); startCalendar.add(Calendar.YEAR, 1); } while (startCalendar.get(Calendar.YEAR) != y2); } return days; } }