Java Day of countDay(String begin, String end)

Here you can find the source of countDay(String begin, String end)

Description

count Day

License

Open Source License

Declaration

public static long countDay(String begin, String end) 

Method Source Code

//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;
    }
}

Related

  1. calcDay(String date1, String date2, String format)
  2. calcSunday(String queryDate)
  3. CountCmpHolidays(Date stdate, Date enddate, String[] CmpHoliDays)
  4. endOfTheDay(Date date)
  5. formatDate(String day)
  6. formatDay(final Date time)
  7. formatDayTime(String day)