Here you can find the source of countDay(String begin, String end)
public static long countDay(String begin, String end)
//package com.java2s; /******************************************************************************* * @FileName: AccountDateUtil.java 2013-7-9 ????2:21:08 * @Author: zhangzhia// w w w. java 2 s. c om * @Copyright: 2013 YUTONG Group CLW. All rights reserved. * @Remarks: YUTONG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *******************************************************************************/ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long countDay(String begin, String end) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date beginDate, endDate; long day = 0; try { beginDate = format.parse(begin); endDate = format.parse(end); day = (endDate.getTime() - beginDate.getTime()) / (24 * 60 * 60 * 1000); } catch (ParseException e) { e.printStackTrace(); } return day; } }