// Path: backbone/src/main/java/org/researchstack/backbone/ui/step/body/BodyAnswer.java
// public class BodyAnswer {
//     public static final BodyAnswer VALID = new BodyAnswer(true, 0);
//     public static final BodyAnswer INVALID = new BodyAnswer(false,
//             R.string.rsb_invalid_answer_default);
// 
//     private boolean isValid;
//     private int reason;
//     private String[] params;
// 
//     public BodyAnswer(boolean isValid, @StringRes int reason, String... params) {
//         this.isValid = isValid;
//         this.reason = reason;
//         this.params = params;
//     }
// 
//     public boolean isValid() {
//         return isValid;
//     }
// 
//     @StringRes
//     public int getReason() {
//         return reason;
//     }
// 
//     public String[] getParams() {
//         return params;
//     }
// 
//     public String getString(Context context) {
//         if (getParams().length == 0) {
//             return context.getString(getReason());
//         } else {
//             return context.getString(getReason(), getParams());
//         }
//     }
// }


import org.researchstack.backbone.R;
import org.researchstack.backbone.ui.step.body.BodyAnswer;
import java.util.Calendar;
import java.util.Date;
package org.researchstack.backbone.answerformat;



public class BirthDateAnswerFormat extends DateAnswerFormat {
    private final int minAge;
    private final int maxAge;

    public BirthDateAnswerFormat(Date defaultDate, int minAge, int maxAge) {
        super(DateAnswerStyle.Date, defaultDate, dateFromAge(maxAge), dateFromAge(minAge));
        this.minAge = minAge;
        this.maxAge = maxAge;
    }

    private static Date dateFromAge(int age) {
        Calendar calendar = Calendar.getInstance();
        if (age != 0) {
            calendar.add(Calendar.YEAR, -age);
            return calendar.getTime();
        }

        return null;
    }

    @Override
// Path: backbone/src/main/java/org/researchstack/backbone/ui/step/body/BodyAnswer.java
// public class BodyAnswer {
//     public static final BodyAnswer VALID = new BodyAnswer(true, 0);
//     public static final BodyAnswer INVALID = new BodyAnswer(false,
//             R.string.rsb_invalid_answer_default);
// 
//     private boolean isValid;
//     private int reason;
//     private String[] params;
// 
//     public BodyAnswer(boolean isValid, @StringRes int reason, String... params) {
//         this.isValid = isValid;
//         this.reason = reason;
//         this.params = params;
//     }
// 
//     public boolean isValid() {
//         return isValid;
//     }
// 
//     @StringRes
//     public int getReason() {
//         return reason;
//     }
// 
//     public String[] getParams() {
//         return params;
//     }
// 
//     public String getString(Context context) {
//         if (getParams().length == 0) {
//             return context.getString(getReason());
//         } else {
//             return context.getString(getReason(), getParams());
//         }
//     }
// }


// Path: backbone/src/main/java/org/researchstack/backbone/answerformat/BirthDateAnswerFormat.java
import org.researchstack.backbone.R;
import org.researchstack.backbone.ui.step.body.BodyAnswer;
import java.util.Calendar;
import java.util.Date;

package org.researchstack.backbone.answerformat;



public class BirthDateAnswerFormat extends DateAnswerFormat {
    private final int minAge;
    private final int maxAge;

    public BirthDateAnswerFormat(Date defaultDate, int minAge, int maxAge) {
        super(DateAnswerStyle.Date, defaultDate, dateFromAge(maxAge), dateFromAge(minAge));
        this.minAge = minAge;
        this.maxAge = maxAge;
    }

    private static Date dateFromAge(int age) {
        Calendar calendar = Calendar.getInstance();
        if (age != 0) {
            calendar.add(Calendar.YEAR, -age);
            return calendar.getTime();
        }

        return null;
    }

    @Override
    public BodyAnswer validateAnswer(Date resultDate) {