Get field value from Calendar
int get(int field)
- Returns the value of the given calendar field.
int getActualMaximum(int field)
- Returns the maximum value that the specified calendar field could have, given the time value of this Calendar.
int getActualMinimum(int field)
- Returns the minimum value that the specified calendar field could have, given the time value of this Calendar.
int getFirstDayOfWeek()
- Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
int getMinimalDaysInFirstWeek()
- Gets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1.
Date getTime()
- Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").
long getTimeInMillis()
- Returns this Calendar's time value in milliseconds.
TimeZone getTimeZone()
- Gets the time zone.
Display Day of Week
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar now = Calendar.getInstance();
System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-"
+ now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
String[] strDays = new String[] { "Sunday", "Monday", "Tuesday",
"Wednesday", "Thusday", "Friday", "Saturday" };
System.out.println("Current day is : "
+ strDays[now.get(Calendar.DAY_OF_WEEK) - 1]);
}
}
The output:
Current date : 10-30-2010
Current day is : Saturday