clear(int): This method is available in java.util.Calendar class of Java.
Syntax:
void java.util.Calendar.clear(int field)
This method takes one argument of type int as its parameter. This method sets the given calendar field value and the time value of this Calendar undefined.
Parameters: One parameter is required for this method.
field: the calendar field to be cleared.
Returns: NA
Exceptions: NA
Approach
Java
import java.util.Calendar;public class Calendarclear2 {public static void main(String[] args) {// create a calendarCalendar calendar = Calendar.getInstance();int field = 1;calendar.clear(field);System.out.println(calendar.getTime());}}
Output:
Tue Jan 20 21:17:17 IST 1970
No comments:
Post a Comment