Javatpoint Logo
Javatpoint Logo

Calendar before() Method

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

Parameter

When - when is the Object that is to be compared.

Returns

This method return True or false value

Throws

NA

Example 1

Test it Now

Output:

Current date: Mon Jul 30 04:08:30 PDT 2018
Year is 2015
Date Thu Jul 30 04:08:30 PDT 2015 is before current date.

Example 2

Test it Now

Output:

Current date: Mon Jul 30 04:13:04 PDT 2018
Year is 4
Date Wed May 30 04:13:04 PDT 2018 is before current date.

Example 3

Test it Now

Output:

Current date: Mon Jul 30 06:19:04 PDT 2018
Year is 23
Date Mon Jul 23 06:19:04 PDT 2018 is before current date.

Example 4

Test it Now

Output:

Current date: Mon Jul 30 06:23:37 PDT 2018
Now date is  Tue Jul 31 06:23:37 PDT 2018
Now date is  Tue Jul 31 07:00:37 PDT 2018
Now date is  Tue Jul 31 07:00:30 PDT 2018



Please Share

facebook twitter google plus pinterest