Here you can find the source of getTimeOfDate(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String getTimeOfDate(Date date)
//package com.java2s; /**//from ww w.j av a 2 s . c om * Copyright (C) 2013 Company. All Rights Reserved. * * This software is the proprietary information of Company . * Use is subjected to license terms. * * @since Jul 17, 2013 11:48:25 PM * @author SPA * */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** * This method is used for getting * * @param date * @return */ public static String getTimeOfDate(Date date) { Calendar calStart = new GregorianCalendar(); calStart.setTime(date); String hour = String.valueOf(calStart.get(Calendar.HOUR_OF_DAY)); String zero = "0"; if (hour.length() < 2) { hour = zero.concat(hour); } String min = String.valueOf(calStart.get(Calendar.MINUTE)); if (min.length() < 2) { min = zero.concat(min); } String sec = String.valueOf(calStart.get(Calendar.SECOND)); if (sec.length() < 2) { sec = zero.concat(sec); } return hour.concat(min.concat(sec)); } }