after(Object): This method is available in java.util.Calendar class of Java.
Syntax:
boolean java.util.Calendar.after(Object when)
This method takes one argument of type Object as its parameter. This method returns whether this Calendar represents a time after the time represented by the specified Object.
Parameters: One parameter is required for this method.
when: the Object to be compared.
Returns: true if the time of this Calendar is after the time represented by when; false otherwise.
Exceptions: NA
Approach
Java
import java.util.Calendar;public class Calendarafter {public static void main(String[] args) {// create a calendarCalendar calendar = Calendar.getInstance();Calendar when = Calendar.getInstance();when.add(Calendar.DATE, -1);System.out.println(calendar.after(when));}}
Output:
true
No comments:
Post a Comment