Calendar class Methods in Java Part -III

java.util.Calendar

The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.

Some methods of  Calendar


hashCode(): This method returns a hash code for this calendar.


isLenient(): This method tells whether date/time interpretation is to be lenient.


isSet(int): This method determines if the given calendar field has a value set.


isWeekDateSupported(): This method returns whether this Calendar supports week dates.


roll(int, boolean):  This method adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields.


roll(int, int): This method adds the specified (signed) amount to the specified calendar field without changing larger fields.


set(int, int): This method sets the given calendar field to the given value.


set(int, int, int): This method sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH. Previous values of other calendar fields are retained.


set(int, int, int, int, int): This method sets the values for the calendar fields YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, and MINUTE.


set(int, int, int, int, int, int): This method sets the values for the fields YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, and SECOND.


setFirstDayOfWeek(int):  This method sets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.


setLenient(boolean): This method specifies whether or not date/time interpretation is to be lenient.


setMinimalDaysInFirstWeek(int): This method sets the minimal days required in the first week of the year.


setTime(Date): This method sets this Calendar's time with the given Date.


setTimeInMillis(long): This method sets this Calendar's current time from the given long value.


setTimeZone(TimeZone): This method sets the time zone with the given time zone value.


setWeekDate(int, int, int): This method sets the date of this Calendar with the given date specifiers - week year, week of the year, and day of the week.


toInstant(): This method converts this object to an Instant.


toString(): This method returns a string representation of this calendar.


Some more Methods of Calendar class Part -I


Some more Methods of Calendar class Part -II


No comments:

Post a Comment