Here you can find the source of getTimeOnly(Date date)
public static Date getTimeOnly(Date date)
//package com.java2s; /*//from ww w .j a v a 2s . co m * Copyright 2016 janobono. All rights reserved. * Use of this source code is governed by a Apache 2.0 * license that can be found in the LICENSE file. */ import java.util.Calendar; import java.util.Date; public class Main { public static Date getTimeOnly(Date date) { if (date == null) { return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.YEAR, 1970); calendar.set(Calendar.DAY_OF_YEAR, 1); return calendar.getTime(); } }