Java Minute Calculate getIntevalMinutes(String startDate, String endDate)

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

Description

get Inteval Minutes

License

Open Source License

Declaration

public static long getIntevalMinutes(String startDate, String endDate) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long getIntevalMinutes(String startDate, String endDate) {
        try {/*  www. j ava 2s  . c o m*/
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            Date d1 = sdf.parse(startDate);
            Date d2 = sdf.parse(endDate);
            long minute = (d2.getTime() - d1.getTime()) / 1000 / 60;
            return minute;
        } catch (Exception ee) {
            System.out.println(ee);
            return 0;
        }
    }

    public static Date parse(String strDate, String pattern) throws ParseException {
        try {
            return getFormatter(pattern).parse(strDate);
        } catch (ParseException pe) {
            throw new ParseException("Method parse in Class DateUtil  err: parse strDate fail.",
                    pe.getErrorOffset());
        }
    }

    private static SimpleDateFormat getFormatter(String parttern) {
        return new SimpleDateFormat(parttern);
    }
}

Related

  1. formatDateMinutes(Date myDate, String pattern)
  2. getAlarmMinutes(String dtStart, String dtAlarm, Logger logger)
  3. getCurrCustomMinuteDate(String formatStr, int changeMinute)
  4. getForwardTimeByMinute(int minute, String format)
  5. getFutureDate(int _minutes)
  6. getTime(int minuteDelt)
  7. getTimeAddMinute(String time, int minute)
  8. getTimeInDate(int offSetInMinutes)
  9. getTravelTimeinMinutes(String startTime, String endTime)