Java Date to Minute getMinutes(Date time)

Here you can find the source of getMinutes(Date time)

Description

Returns the minutes from midnight for the specified time.

License

Open Source License

Parameter

Parameter Description
time the time

Return

the minutes from midnight for time

Declaration

public static int getMinutes(Date time) 

Method Source Code


//package com.java2s;
/*/*from w ww  . j a va 2s .c  om*/
 * Version: 1.0
 *
 * The contents of this file are subject to the OpenVPMS License Version
 * 1.0 (the 'License'); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.openvpms.org/license/
 *
 * Software distributed under the License is distributed on an 'AS IS' basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Copyright 2015 (C) OpenVPMS Ltd. All Rights Reserved.
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * Returns the minutes from midnight for the specified time.
     *
     * @param time the time
     * @return the minutes from midnight for {@code time}
     */
    public static int getMinutes(Date time) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int mins = calendar.get(Calendar.MINUTE);
        return (hour * 60) + mins;
    }
}

Related

  1. getMinute(Date date)
  2. getMinute(Date date)
  3. getMinute(java.util.Date date)
  4. getMinuteOfHour(final Date date)
  5. getMinutes(Date d)
  6. getMinutes(final Date date)
  7. getMinutesInDay(Date d)
  8. getMinutesOfHour(Date dt)
  9. minute(Date date)