Java Calendar ComputeFields() Method

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.

Syntax

Parameter

NA

Returns

This method does not return any value.

Throws

NA

Example 1

Output:

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 2

Output:

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 3

Output:

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 4

Output:

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