Java Date to Day getDay(Date dateParam)

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

Description

get Day

License

Open Source License

Declaration

public static int getDay(Date dateParam) 

Method Source Code

//package com.java2s;

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

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

    public static long getTime(Date dateParam) {
        if (dateParam == null) {
            throw new IllegalArgumentException("The dateParam  must not be null");
        }
        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. getDay(Date date)
  2. getDay(Date date)
  3. getDay(Date date)
  4. getDay(Date date)
  5. getDay(Date date, int day)
  6. getDay(java.util.Date date)
  7. getDay(String strDate)
  8. getDayBetween(Date startDate, Date endDate)
  9. getDayCount(java.util.Date _startDate, java.util.Date _endDate)