Java Hour getHourAndMinutes(Date dt)

Here you can find the source of getHourAndMinutes(Date dt)

Description

Get and return the hours and minutes from the given Date dt, ex: 11:30

License

Open Source License

Parameter

Parameter Description
dt The given Date

Return

hrsMin The hours and minutes of date in format hh:mm

Declaration

public static String getHourAndMinutes(Date dt) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**// www . j a  va2 s.  c o m
     * Get and return the hours and minutes from the given Date dt, ex: 11:30
     * 
     * @param dt
     *            The given Date
     * 
     * @return hrsMin The hours and minutes of date in format hh:mm
     */
    public static String getHourAndMinutes(Date dt) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        return (cal.get(Calendar.HOUR) + ":" + (cal.get(Calendar.MINUTE)));
    }
}

Related

  1. getHour(String dateTime)
  2. getHour12(Date date)
  3. getHourAfter(Date date, int hour)
  4. getHourAfter(final Date _from, final int _hours)
  5. getHourAndMin(long time)
  6. getHourBeforeTime(int hour)
  7. getHourByZore(int hour)
  8. getHourDetails(int timeInfo)
  9. getHourFormatedTwoDigit()