Java examples for java.util:Time
Resets the time in the specified datetime object to 0:00:00.000.
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { Date date = new Date(); System.out.println(normalizeTimeDown(date)); }/* w w w. j ava2s .c o m*/ /** * Resets the time in the specified datetime object to 0:00:00.000. * * @param date * the date to operate on * @return the altered datetime object */ @Deprecated public static Date normalizeTimeDown(Date date) { date.setHours(0); date.setMinutes(0); date.setSeconds(0); date.setTime((date.getTime() / 1000) * 1000); return date; } /** * Resets the time in the specified datetime object to 0:00:00.000. * * @param calendar * the datetime object to operate on * @return the altered datetime object */ public static Calendar normalizeTimeDown(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; } }