Set and get the day of the week in Java
Description
The following code shows how to set and get the day of the week.
Example
//from w w w . j a v a 2 s .c o m
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] a) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
int day = calendar.get(Calendar.DAY_OF_WEEK);
System.out.println(day);
}
}
The code above generates the following result.