Java Millisecond Current Get getMillisOfTowDiffDate(String p_startDate, String p_endDate)

Here you can find the source of getMillisOfTowDiffDate(String p_startDate, String p_endDate)

Description

get Millis Of Tow Diff Date

License

Apache License

Declaration

public static long getMillisOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;

import java.util.Date;

public class Main {

    public static long getMillisOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException {
        Date l_startDate = toUtilDateFromStrDateByFormat(p_startDate, "yyyy-MM-dd HH:mm:ss");
        Date l_endDate = toUtilDateFromStrDateByFormat(p_endDate, "yyyy-MM-dd HH:mm:ss");
        long l_startTime = getMillisOfDate(l_startDate);
        long l_endTime = getMillisOfDate(l_endDate);
        return (long) (l_endTime - l_startTime);
    }//w ww .  j  a va  2 s.  co  m

    public static long getMillisOfTowDiffDate(Date p_startDate, Date p_endDate) {
        long l_startTime = getMillisOfDate(p_startDate);
        long l_endTime = getMillisOfDate(p_endDate);
        return (long) (l_endTime - l_startTime);
    }

    public static java.util.Date toUtilDateFromStrDateByFormat(String p_strDate, String p_format)
            throws ParseException {
        java.util.Date l_date = null;
        java.text.DateFormat df = new java.text.SimpleDateFormat(p_format);
        if (p_strDate != null && (!"".equals(p_strDate)) && p_format != null && (!"".equals(p_format))) {
            l_date = df.parse(p_strDate);
        }
        return l_date;
    }

    public static long getMillisOfDate(java.util.Date p_date) {
        java.util.Calendar c = java.util.Calendar.getInstance();
        c.setTime(p_date);
        return c.getTimeInMillis();
    }
}

Related

  1. getMillisFromISO8601(Object iso8601)
  2. getMillisFromRFC822String(Object rfc822)
  3. getMillisFromString(String s)
  4. getMillisFromYYYYMMDD(Object yyyymmdd)
  5. getMillisId()
  6. getMillon(long time)