// Path: app/src/main/java/org/nutritionfacts/dailydozen/exception/InvalidDateException.java
// public class InvalidDateException extends Exception {
//     private final String invalidDateString;
// 
//     public InvalidDateException(String invalidDateString) {
//         this.invalidDateString = invalidDateString;
//     }
// 
//     @NonNull
//     @Override
//     public String toString() {
//         return String.format("InvalidDateException{invalidDateString='%s'}", invalidDateString);
//     }
// }


import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;
import org.nutritionfacts.dailydozen.exception.InvalidDateException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import hirondelle.date4j.DateTime;
import timber.log.Timber;
        // NOTE: This method used to be the following line. However, because of a bug in Caldroid, I had to
        // change the implementation to return a DateTime with 0 in the time fields instead of null otherwise the
        // food servings history chart would not show events.
        // return DateTime.forDateOnly(year, month, day);

        return new DateTime(year, month, day, 0, 0, 0, 0);
    }

    private void setDate(DateTime dateTime) {
        this.date = Long.parseLong(getDateString(dateTime));

        this.year = dateTime.getYear();
        this.month = dateTime.getMonth();
        this.day = dateTime.getDay();
    }

    public long getDate() {
        return date;
    }

    @NonNull
    @Override
    public String toString() {
        return getDateTime().format("WWW, MMM D", Locale.getDefault());
    }

    public String getDayOfWeek() {
        return getDateTime().format("D (WWW)", Locale.getDefault());
    }

// Path: app/src/main/java/org/nutritionfacts/dailydozen/exception/InvalidDateException.java
// public class InvalidDateException extends Exception {
//     private final String invalidDateString;
// 
//     public InvalidDateException(String invalidDateString) {
//         this.invalidDateString = invalidDateString;
//     }
// 
//     @NonNull
//     @Override
//     public String toString() {
//         return String.format("InvalidDateException{invalidDateString='%s'}", invalidDateString);
//     }
// }


// Path: app/src/main/java/org/nutritionfacts/dailydozen/model/Day.java
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;
import org.nutritionfacts.dailydozen.exception.InvalidDateException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import hirondelle.date4j.DateTime;
import timber.log.Timber;

        // NOTE: This method used to be the following line. However, because of a bug in Caldroid, I had to
        // change the implementation to return a DateTime with 0 in the time fields instead of null otherwise the
        // food servings history chart would not show events.
        // return DateTime.forDateOnly(year, month, day);

        return new DateTime(year, month, day, 0, 0, 0, 0);
    }

    private void setDate(DateTime dateTime) {
        this.date = Long.parseLong(getDateString(dateTime));

        this.year = dateTime.getYear();
        this.month = dateTime.getMonth();
        this.day = dateTime.getDay();
    }

    public long getDate() {
        return date;
    }

    @NonNull
    @Override
    public String toString() {
        return getDateTime().format("WWW, MMM D", Locale.getDefault());
    }

    public String getDayOfWeek() {
        return getDateTime().format("D (WWW)", Locale.getDefault());
    }

    public static Day getByDate(String dateString) throws InvalidDateException {