Java Hour getHourMin(Date date)

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

Description

get Hour Min

License

Open Source License

Declaration

public static String getHourMin(Date date) 

Method Source Code

//package com.java2s;
/**/*from   w  w w . j  a  v a 2 s.  co  m*/
 * Copyright &copy; 2012-2013 <a href="https://github.com/sccl/attech">attech</a> All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */

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

public class Main {

    public static String getHourMin(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        String ohHour = cal.get(Calendar.HOUR_OF_DAY) + "";
        String ohMinute = cal.get(Calendar.MINUTE) + "";
        if (ohMinute.length() == 1) {
            ohMinute = "0" + ohMinute;
        }
        if (ohHour.length() == 1) {
            ohHour = "0" + ohHour;
        }
        String ohTime = ohHour + ":" + ohMinute;
        return ohTime;
    }
}

Related

  1. getHourByZore(int hour)
  2. getHourDetails(int timeInfo)
  3. getHourFormatedTwoDigit()
  4. getHourFromDate(Date date)
  5. getHourInt()
  6. getHourMinuteSecondByMisSecond(long misSecond)
  7. getHourMinuteString(Date dateTime)
  8. getHourMinuteString(Date t)
  9. getHourOfDay(Calendar date)