Java Day of Week getWeek(Date dateParam)

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

Description

get Week

License

Open Source License

Declaration

public static int getWeek(Date dateParam) 

Method Source Code

//package com.java2s;

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

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

    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. getSundayDate(int week, int year)
  2. getSundayOfWeek(Date date)
  3. getThisweekFirst(Date early)
  4. getWeek(Date date)
  5. getWeek(Date date)
  6. getWeek(Date today)
  7. getWeek(java.util.Date date)
  8. getWeek(java.util.Date today)
  9. getWeekBegin(Date date)