public static String[] getLatelyTenMinsTimeslot(String time){
String [] date = new String [2];
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.string2Date(time, "yyyy-MM-dd HH:mm:ss"));
calendar.set(Calendar.MINUTE, (calendar.get(Calendar.MINUTE))/10*10);
calendar.set(Calendar.SECOND,0);
Date early = calendar.getTime();
calendar.add(Calendar.MINUTE, 10);
Date late = calendar.getTime();
date[0] = new SimpleDateFormat("yyyyMMddHHmmss").format(early);
date[1] = new SimpleDateFormat("yyyyMMddHHmmss").format(late);
return date;
time 传入 2020-05-20 14:22:36
输出结果为 date[0] = 20200520142000
date[1] = 20200520143000
public static String[] getLatelyTenMinsTimeslot(String time){ String [] date = new String [2]; Calendar calendar = Calendar.getInstance(); calendar.setTime(DateUtil.string2Date(time, "yyyy-MM-dd HH:mm:ss")); calendar.set(Calendar.MINUTE.
private List<String> getLatelyTenMinsTimeslot(){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MINUTE, (calendar.get(Calendar....
public static Map<String, String> getMillisEndWithMinute0or20_2() {
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter sdfDay = DateTimeFormatter.ofPattern("yyyyMMdd");
final Map<String, String>.
public static List<String> findDates(Date dBegin, Date dEnd){
List<String> lDate = new ArrayList<String>();
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd...
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
System.out.println("当前时间:" + sdf.format(now));
Date afterDate = new Date(now .getTime() + 600000);
System.out.println(sdf.format(after
private Date subtractTime(Date date, int amount) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s.
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
int minute = calendar.get(Calendar.MINUTE);
minute = minute / 5 * 5;
calendar.set(Calendar.MINUTE, minute);
Date date = calendar.getTime();
注意:以上代码中获取的时间是当前时间的整5分钟时间点,如果需要获取其它时间点的整5分钟时间,则需要先将所需时间设置到Calendar对象中。