In mongodb adhoc query, before executing the query, how to format the date type element to dd\\mm\\yyyy
format and then execute the query?
Date
class has a before(date)
or after(date)
method... It is easy to use: no conversion to seconds/milliseconds.
public void execute(Tuple input) {
try {
date=(Date) input.getValueByField("date");
boolean before = date.before(myDate); // compare the data retrieved with your date.
if (before) {
...
} else {
...
}
} catch (Exception e) {
logger.error("Error...", e);
}
This approach is easier than the accepted answer..