What is the preferred way of comparing dates in JDBC + SQLite
I find they are doing pretty much the same thing
But they also share a common problem - when you don't specify the year, the predicate would be wrong
But in my application, there may be times when year will not be given.
Like The database has a birthday which contains just month and day
What is your opinion?
What are you trying to achieve? Do you have a table containing the birthdays and are you trying to list all birthdays that occur in certain interval?
Also, it doesn't make sense asking us whether your code will work. You can easily test that yourself, can't you? If you want to ask whether a specific approach will work, it would be better if you described that approach in English instead of asking us to deduce it from your code.
In any case, I'd prefer to perform the comparison on the dates, not their textual representations. For example, I'd get the day and month, plugged in the current year, and compared that date to the interval of my interest. If the interval overlaps the next year too, I'd try the comparison with the next year too. But this is just my preference. It is certainly possible to implement the logic using the texts, not the dates, I just consider the version with the DATE datatype more readable.
Another possibility, assuming the interval of interest is always short, would be to create the MMDD representation of every day in the interval and use just an IN operator to select matching records.