Here you can find the source of weeksBetween(Date date1, Date date2)
public static int weeksBetween(Date date1, Date date2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int weeksBetween(Date date1, Date date2) { int days = daysBetween(date1, date2); return (days % 7) == 0 ? (days / 7) : (days / 7) + 1; }/*w w w .j a va 2 s . c om*/ public static int daysBetween(Date date1, Date date2) { if (date1 == null || date2 == null) { return 0; } Calendar cal = Calendar.getInstance(); cal.setTime(date1); long time1 = cal.getTimeInMillis(); cal.setTime(date2); long time2 = cal.getTimeInMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); } }