Java Calendar ComputeFields() Method3 Nov 2024 | 3 min read The computeFields() method of java Calendar class is protected and abstract method. It converts the current millisecond time value to calendar field values in fields[].This allows syncing up with the calendar field values with a new time that is set for the calendar object. SyntaxParameterNA ReturnsThis method does not return any value. ThrowsNA Example 1Output: The current date is : Tue Jul 31 20:06:08 PDT 2018 New date is : Thu Jan 01 00:00:00 PST 3018 New date is : Thu Jan 01 00:00:00 PST 3018 Example 2Output: The current date is : Tue Jul 31 20:14:45 PDT 2018 New date is : Sun Nov 01 00:00:00 PST 1970 New date is : Sun Nov 01 00:00:00 PST 1970 Example 3Output: The current date is : Tue Jul 31 20:19:24 PDT 2018 New date is : Sat Jan 10 00:00:00 PST 1970 New date is : Sat Jan 10 00:00:00 PST 1970 Example 4Output: The current date is : Tue Jul 31 20:21:45 PDT 2018 New date is : Thu Jan 01 23:16:40 PST 1970 New date is : Thu Jan 01 23:16:40 PST 1970 Next TopicJava-calendar-equals-method |
The getMaximum() method of java.util.Calendar class is an abstract method. This method is used with calendar object to get the maximum value of specified calendar field as parameter. Syntax public abstract int getMaximum(int field) Parameter field - the calendar field. Returns The maximum value for the given calendar field. Throws Do not throw any...
3 min read
The getTimeZone() method of java.util.Calendar class gets the TimeZone of calendar object and returns a TimeZone object. Syntax public TimeZone getTimeZone() Parameter No parameter is passed. Returns Returns the TimeZone object. Throws Does not throw an exception. Example 1 import java.util.Calendar; import java.util.TimeZone; public class JavaCalendargetTimeZoneExample1 { public static void main(String[] args) { Calendar mycal = Calendar.getInstance(); ...
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. Syntax public final void setTime(Date date) Parameter date - a date object. Returns Does not return value. Throws Does not throw Exception. Example 1 import java.util.*; public class...
2 min read
The isLenient() method of Calendar class returns the Boolean value true if the interpretation mode of this calendar is lenient; false otherwise. Syntax Public boolean isLenient() Parameter No parameter is passed. Returns Returns Boolean value. Throws Does not throw Exception. Example 1 import java.util.*; public class JavaCalendarisLenintExample1 { public static void main(String[] args) { ...
2 min read
The SetFirstDayOfWeek() method of Calendar class is used to set the first day of the week. The value which is to be set as the first day of the week is passed as the parameter. Syntax public void setFirstDayOfWeek(int value) Parameter value - It is to be set as the...
3 min read
java.util.Calendar.before() is a method in Calendar class of java.util package. The method returns true if the time represented by this Calendar is before the time represented by when Object. If it is not the case, false is returned. Syntax public boolean before(Object when) Parameter When - when is the Object...
4 min read
The getTime() method of java.util.Calendar class is a final method. This method gets the time value of calendar object and returns the date. Syntax public final Date getTime() Parameter No parameter is passed. Returns Returns a date which represents time value of calendar object. Throws Does not throw exception. Example 1 import java.util.*; public class JavaCalendargetTimeExample1 extends...
2 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 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 roll () method of Calendar class increases or decreases the specified calendar field by one unit without affecting the other field. For example, if the YEAR field is passed as the parameter. It will roll only the YEAR field. The roll() method is overloaded as...
2 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