Here you can find the source of extractDayOfWeek(Date date)
Parameter | Description |
---|---|
date | the date instance from which the day of week is to be extracted. |
public static int extractDayOfWeek(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /**/* ww w .j a v a2 s . c o m*/ * Extract the day of the week from a {@link Date} instance. * * @param date the date instance from which the day of week is to be extracted. * @return the day of the week from the specified {@link Date} instance. * Sunday is represented by 1, Monday by 2, through to Saturday by 7. * These correspond to the values returned by {@link java.util.Calendar#get(int)}. * The constants {@link java.util.Calendar#SUNDAY}, {@link java.util.Calendar#MONDAY} ... may prove useful. */ public static int extractDayOfWeek(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal.get(Calendar.DAY_OF_WEEK); } }