Java Date to Time getTimeOnly(Date date)

Here you can find the source of getTimeOnly(Date date)

Description

get Time Only

License

Open Source License

Declaration

public static Date getTimeOnly(Date date) 

Method Source Code


//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();
    }
}

Related

  1. getTimeLocalWithoutDst(java.util.Date d)
  2. getTimeLocalWithoutDst(java.util.Date d)
  3. getTimeMargin(String dateTime)
  4. getTimeMax(Date date)
  5. getTimeOfDate(Date date)
  6. getTimeOnly(Date date)
  7. getTimeOnly(final Date oDate)
  8. getTimePart(Date dateObject)
  9. getTimePeriod(Date date)