How to delete firebase data after "n" days
<p>I want do delete some old data from my Firebase, and I have a hard time do make it work.</p>

<p>I tried this solution found here: <a href="https://stackoverflow.com/questions/15990681/firebase-chat-removing-old-messages">Firebase chat - removing old messages</a></p>

<p>but this isn't deprecated.</p>

<p>so I try it this way:</p>

<pre><code>ChildEventListener childEventListener = new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -30);

        Log.d(TAG, "onChildAdded:" + dataSnapshot.getKey());

        String key = dataSnapshot.getKey();

        Marker retrievemarker =dataSnapshot.getValue(Marker.class);
        Calendar t3 = new           
        GregorianCalendar
        (c.get(Calendar.YEAR),
         c.get(Calendar.MONTH),
         retrievemarker.getSavedate());

        int date1= calendar.get(Calendar.DATE);
        int date2= t3.get(Calendar.DATE);

        Log.d("date1",""+date1);
        Log.d("date2",""+date2);

        if( date1 == date2 ){

            myRef.child(key).setValue(null);

        }
</code></pre>

<p>for explanation:
In my Firebase I save a object named Marker, this object got a variable to store the savedate, the date where the object was saved in the Firebase.</p>

<pre><code>int date = c.get(Calendar.DATE);
marker.setSavedate(date);
</code></pre>

<p>I want to delete the object in the Firebase after 30 days. So I try to subtract 30 days from the Date Today than i want to compare this with the savedate from the Object if it equals i will delete the object from the Firebase.</p>

<p>For the Subtraction I refer to an answer from the following question: <a href="https://stackoverflow.com/questions/212321/how-to-subtract-x-days-from-a-date-using-java-calendar">How to subtract X days from a date using Java calendar?</a></p>

<p>But it doesn´t work. If I add a Object today to the Firebase the two dates are always equal. 
So I guess the subtraction doesn´t work. </p>

<p>What am I doing wrong?</p>