Java Day day2Day(String startDate, String endDate, String format)

Here you can find the source of day2Day(String startDate, String endDate, String format)

Description

day Day

License

Open Source License

Declaration


public static long day2Day(String startDate, String endDate, String format) throws Exception 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long day2Day(String startDate, String endDate, String format) throws Exception {
        if (format == null)
            format = "yyyy/MM/dd HH:mm:ss.SSS";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date sDate;/*  w ww .j a va  2  s .co  m*/
        Date eDate;
        long day2day = 0;
        try {
            sDate = sdf.parse(startDate);
            eDate = sdf.parse(endDate);
            day2day = (eDate.getTime() - sDate.getTime()) / (1000 * 60 * 60 * 24);
        } catch (Exception e) {
            throw new Exception("wrong format string");
        }

        return day2day;
    }
}

Related

  1. dateValue(Date d)
  2. day2ThuesDay(Date date)
  3. dayDiff(Date date1, String date2)
  4. dayEnd(Date date)
  5. dayFillter(String text, String type)