if(startTime!=null&&!startTime.equals("")&&endTime!=null&&!endTime.equals("")){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf2.setTimeZone(TimeZone.getTimeZone("UTC")); try { Date startDate = sdf.parse(startTime); Date endDate = sdf.parse(endTime); sb.append(" AND f.file_time >='"+sdf2.format(startDate)+"' "); sb.append(" AND f.file_time <='"+sdf2.format(endDate)+"' "); } catch (ParseException e) { e.printStackTrace(); } }