What does it mean to clear in a Calendar variable?

2

I want to know when to use clear () and why to use it.

SimpleDateFormat simpleDateFormart = new SimpleDateFormat("dd/MM/yyyy");

Date data1 = simpleDateFormart.parse("18/12/1986");
Date data2 = simpleDateFormart.parse("25/01/2017");

Calendar mD = Calendar.getInstance();
Calendar mD2 = Calendar.getInstance();

mD.clear();
mD2.clear();
    
asked by anonymous 25.01.2017 / 19:23

1 answer

1

The method clear () places all the Calendar fields and their value (time value) as "undefined".
This implies that the method isSet() of any field returns false .

The "undefined" value is a detail of each implementation, for example the GregorianCalendar uses January 1, 1970 00: 00: 00.000 GMT p>

Having as an example the code you posted after% w / w% w / w% will be 1970.

Source: Class Calendar.

(1) In computing, time is counted against this point in time ( Epoch / Season . Any other point in time is defined relative to it and represented as the difference in milliseconds between them.

    
25.01.2017 / 19:57