Here you can find the source of getTimeFromDate(final Date date)
Date
object.
Parameter | Description |
---|---|
date | The date to get the timestamp from. |
public static int getTimeFromDate(final Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**//from ww w .ja v a2s . c om * Create an integer time from a <code>Date</code> object. * * @param date * The date to get the timestamp from. * @return The time as an integer formatted as "HHmm". */ public static int getTimeFromDate(final Date date) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); final int hour = calendar.get(Calendar.HOUR_OF_DAY) * 100; final int minute = calendar.get(Calendar.MINUTE); return hour + minute; } }