use of org.cubeengine.libcube.util.TimeConversionException in project modules-extra by CubeEngine.
the class LookupCommands method readTimeBefore.
private boolean readTimeBefore(QueryParameter params, String beforeString, User user) {
try {
// TODO date too
if (beforeString == null) {
return true;
}
long before = StringUtils.convertTimeToMillis(beforeString);
params.before(new Date(System.currentTimeMillis() - before));
return true;
} catch (TimeConversionException e) {
user.sendTranslated(NEGATIVE, "{input#time} is not a valid time value!", beforeString);
return false;
}
}
use of org.cubeengine.libcube.util.TimeConversionException in project modules-extra by CubeEngine.
the class LookupCommands method readTimeSince.
private boolean readTimeSince(QueryParameter params, String sinceString, User user) {
try {
if (sinceString != null) {
// TODO date too
long since = StringUtils.convertTimeToMillis(sinceString);
params.since(new Date(System.currentTimeMillis() - since));
} else {
// defaulted to last 30 days
params.since(new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30)));
}
return true;
} catch (TimeConversionException e) {
user.sendTranslated(NEGATIVE, "{input#time} is not a valid time value!", sinceString);
return false;
}
}
Aggregations