Get the Day-of-Week for a Particular Date in Java

Description

The following code shows how to get the Day-of-Week for a Particular Date.

Example


/*  w  ww .j a v  a  2s  . c o  m*/
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
  public static void main(String[] argv) throws Exception {

    Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
    int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK); // 6=Friday

    Calendar cal = new GregorianCalendar(2003, Calendar.JANUARY, 1);
    dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 4=Wednesday
  }
}




















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone