SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(Configuration.zoneid));
Calendar startCalendar = Calendar.getInstance(TimeZone.getTimeZone(Configuration.zoneid));
startCalendar.setTimeInMillis(start);
String startStr = sdf.format(startCalendar.getTime());
Calendar endCalendar = Calendar.getInstance(TimeZone.getTimeZone(Configuration.zoneid));
endCalendar.setTimeInMillis(end);
String endStr = sdf.format(endCalendar.getTime());
BasicDBObject dateCondition = new BasicDBObject();
if (start != null && start != 0) {
Date now = cal.getTime();
if (startCalendar.after(now)) {
return Return.FAIL(400, "开始时间 大于 当前时间!");
}
Timestamp starTime = Timestamp.valueOf(startStr);
dateCondition.put("$gte", starTime);
}
if (end != null && end != 0) {
Timestamp endTime = Timestamp.valueOf(endStr);
dateCondition.put("$gte", endTime);
}
logger.info("从" + startStr + "到" + endStr + "jobs信息查询");