Here you can find the source of getTimeOnly(Date date)
Parameter | Description |
---|---|
date | date to be adjusted |
public static Date getTimeOnly(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**/* w w w. ja v a2s. c o m*/ * Returns time without date information. * * @param date date to be adjusted * @return Returns date object without time information */ public static Date getTimeOnly(Date date) { if (null == date) { date = new Date(); } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.YEAR, 0); calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.DAY_OF_MONTH, 0); return calendar.getTime(); } }