Java Date to Time getTime(Date dateParam)

Here you can find the source of getTime(Date dateParam)

Description

get Time

License

Open Source License

Declaration

public static long getTime(Date dateParam) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static long getTime(Date dateParam) {
        if (dateParam == null) {
            throw new IllegalArgumentException("The dateParam  must not be null");
        }/*from  w  w  w .j a v a 2s  . c  o m*/
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(dateParam.getTime());

        int hour = cal.get(Calendar.HOUR);
        int minute = cal.get(Calendar.MINUTE);
        int second = cal.get(Calendar.SECOND);

        long result = hour * 3600 * 1000 + minute * 60 * 1000 + second * 1000;

        return result;
    }
}

Related

  1. getTime(Date date)
  2. getTime(Date date)
  3. getTime(Date date)
  4. getTime(Date date, boolean isEnd)
  5. getTime(Date date, String pattern, Locale locale)
  6. getTime(Date executionTime)
  7. getTime(Date timestamp)
  8. getTime(Date trialTime)
  9. getTime(final Date date, final int day)