Java的Date类型时分秒置0

Date now = new Date();
Calendar cal1 = Calendar.getInstance();
cal1.setTime(now);
// 将时分秒,毫秒域清零
cal1.set(Calendar.HOUR_OF_DAY, 0);
cal1.set(Calendar.MINUTE, 0);
cal1.set(Calendar.SECOND, 0);
cal1.set(Calendar.MILLISECOND, 0);
Date date = cal1.getTime();

你可能感兴趣的:(java3,java,开发语言,后端)