Get the day of the week in Java
Description
The following code shows how to get the day of the week.
Example
//w w w.j a va 2 s. co m
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] argv) throws Exception {
GregorianCalendar newCal = new GregorianCalendar();
int day = newCal.get(Calendar.DAY_OF_WEEK);
newCal = new GregorianCalendar();
newCal.set(1997, 2, 1, 0, 0, 0);
newCal.setTime(newCal.getTime());
day = newCal.get(Calendar.DAY_OF_WEEK);
System.out.println(day);
}
}
The code above generates the following result.