Java Day of calcDay(String date1, String date2, String format)

Here you can find the source of calcDay(String date1, String date2, String format)

Description

calc Day

License

Open Source License

Declaration

public static long calcDay(String date1, String date2, String format) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

    public static long calcDay(String date1, String date2, String format) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(date1));/*  ww  w .ja  va  2s. c o  m*/
        long time1 = cal.getTimeInMillis();
        cal.setTime(sdf.parse(date2));
        long time2 = cal.getTimeInMillis();
        return (time1 - time2) / (1000 * 3600 * 24);
    }
}

Related

  1. calcSunday(String queryDate)
  2. CountCmpHolidays(Date stdate, Date enddate, String[] CmpHoliDays)
  3. countDay(String begin, String end)
  4. endOfTheDay(Date date)