Java Hour getHourMinuteString(Date t)

Here you can find the source of getHourMinuteString(Date t)

Description

get Hour Minute String

License

Open Source License

Declaration

public static String getHourMinuteString(Date t) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Dominik Halfkann, Michael Backhaus, Benjamin Kramer,
 * Fabian K?nig, Karl Stelzner, Stefan Noll and Alexander Schieweck.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html/*from   w w  w.ja  va 2 s  .com*/
 ******************************************************************************/

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

public class Main {
    private static Calendar c1 = Calendar.getInstance();

    public static String getHourMinuteString(Date t) {
        c1.setTime(t);
        String hour = c1.get(Calendar.HOUR_OF_DAY) < 10 ? "0" + c1.get(Calendar.HOUR_OF_DAY)
                : Integer.toString(c1.get(Calendar.HOUR_OF_DAY));
        String minute = c1.get(Calendar.MINUTE) < 10 ? "0" + c1.get(Calendar.MINUTE)
                : Integer.toString(c1.get(Calendar.MINUTE));
        return hour + ":" + minute;
    }
}

Related

  1. getHourFromDate(Date date)
  2. getHourInt()
  3. getHourMin(Date date)
  4. getHourMinuteSecondByMisSecond(long misSecond)
  5. getHourMinuteString(Date dateTime)
  6. getHourOfDay(Calendar date)
  7. getHourOfDay(final Date date)
  8. getHourOfDayInAm(Date dt)
  9. getHourOfWeek(Date dateIn)