Java Day getDays(Date sd, Date ed)

Here you can find the source of getDays(Date sd, Date ed)

Description

get Days

License

Open Source License

Declaration

public static int getDays(Date sd, Date ed) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static int getDays(Date sd, Date ed) {
        return (int) ((ed.getTime() - sd.getTime()) / (3600 * 24 * 1000));
    }//from   w  w w. j av  a  2 s  . c o  m

    public static long getTime() {
        java.util.Date dt = new java.util.Date();
        return dt.getTime();
    }

    public static String getTime(String s) {
        if (s == null || s.equals(""))
            return "";
        String s1 = "";
        try {
            SimpleDateFormat simpledateformat = new SimpleDateFormat(s);
            s1 = simpledateformat.format(Calendar.getInstance().getTime());
        } catch (Exception exception) {
            System.out.println(Calendar.getInstance().toString() + "cannot format time [function:getTime(String)]");
            exception.printStackTrace();
        }
        return s1;
    }
}

Related

  1. getDayOffset(String date, int offset, String format)
  2. getDayofTheDate(Date d1)
  3. getDAYOFWEEK(String strDate)
  4. getDayRange(String bday, String eday)
  5. getDays(Date day, int preDays, String format)
  6. getDays(String yyyy)
  7. getDaysAgo(int interval)
  8. getDaysByYearMonth(String ym)
  9. getDaysForDate(String date)