Java Calendar setTime() Method3 Nov 2024 | 1 min read The setTime () method of java.util.Calendar class is used to set the Time of current calendar object. A Date object id is passed as the parameter into this method. SyntaxParameterdate - a date object. ReturnsDoes not return value. ThrowsDoes not throw Exception. Example 1Output: Date :Sat Nov 23 00:00:00 PST 1996 new Date is :Sun Nov 10 00:00:00 PST 1918 Example 2Output: Date (mycal):Wed Aug 15 19:07:31 PDT 2018 Date (mycal2) :Mon Oct 14 19:07:31 PDT 1996 Next TopicJava-calendar-settimzone-method |
The getAvailableCalendarTypes() method of java.util.Calendar class returns a Set which contains string set of all available calendar type supported by java Runtime Environment. Syntax public static Set<String> getAvailableCalendarTypes() Parameter Doesn't accept any value. Returns Returns all available Calendar type in form of unmodifiable Set Throws InterruptedException Example 1 import java.util.Calendar; import java.util.Set; public class CalendargetavailablecalendartypeExample1 { public static void...
1 min read
The set() method of Calendar class is used to set the specified calendar field by the specified value. Syntax This method is overloaded in the following ways. public void set(int field, int value) public final void set(int year, int month, int date) public final void set(int year,int month, int date, int...
2 min read
The equals() method compares two objects for equality and returns true if they are equal. The equals() method is provided in the Object class. As object class is the super class of all other classes in java. Calendar class inherits the equals() method. It compares this...
3 min read
The get() method of Calender class returns the value of the parameter fields passed into it. Fields like DAY_OF_MONTH, MONTH, YEAR, WEEK, WEEK_OF_YEAR etc are passed as parameter to this method. Syntax public int get(int field) Parameter Any field of calendar is passed as parameter. Returns Return value of passed field...
3 min read
The internalGet() method of java.util.Calendar class is a final, and protected method. This method returns the value of the calendar field passed as a parameter. Syntax protected final int internalGet(int field) Parameter field - the given calendar field. Returns the value for the given calendar field. Throws Does not throw Exception. Example 1 import java.util.GregorianCalendar; public class...
2 min read
This method returns true if the time represented by this Calendar is after the time represented by when Object. If it is not the case, false is returned. Syntax Public boolean after (Object when) Parameter When - the Object of time that is about to be compared. Returns True if the time...
4 min read
The clone() method is a method of object class and Object class is super class of all the classes of java. clone() method can be called for the object of calendar class also. Clone method returns the copy of the object. Syntax public Object clone() Parameter This method does not...
3 min read
The setTimZonee() method of java.util.Calendar class is used to set the TimeZone with the passed TimeZone value(object) as a parameter. Syntax public void setTimeZone(TimeZone value) Parameter value - value which is to set as TimeZone. Returns NA Throws NA Example 1 import java.util.Calendar; import java.util.TimeZone; public class JavaCalendarsetTimeZoneExample1 { public static void main(String[] args) { Calendar mycal = Calendar.getInstance(); ...
2 min read
The getAvailableLocals() method of java.util.Calendar class returns an array of all locales available in java runtime environment. The array of locales contains locales for which localized Calendar instances are available. getAvailableLocals() method is a static method. Syntax public static Locale[] getAvailableLocales() Parameter This method doesn't accept any parameter. Returns This method...
2 min read
//return String The getDisplayName() method of java.util.Calendar class returns String representation of the calendar field value passed as parameter in a given style and local. Style and local are also passed as parameter. If no String representation is available, getDisplayName() returns null value. If String representation...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India