Java Hour Format getHHMM(Date date)

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

Description

get HHMM

License

Open Source License

Declaration

public static String getHHMM(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Boeing.//w  w w  .  j  av  a  2  s  . c  o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String HHMM = "hh:mm";

    public static String getHHMM(Date date) {
        return get(date, HHMM);
    }

    public static String get(Date date) {
        if (date == null) {
            return "";
        }
        return DateFormat.getDateInstance().format(date);
    }

    public static String get(Date date, String pattern) {
        return get(date, new SimpleDateFormat(pattern));
    }

    public static String get(Date date, DateFormat dateFormat) {
        if (date == null) {
            return "";
        }
        String result = dateFormat.format(date);
        return result;
    }
}

Related

  1. formatXEP0082Date(Date date)
  2. formatXsdDate (final Date date)
  3. formatXsdDateTime(Date d)
  4. getFormattedHoursByMinutes(int minutes)
  5. getHHmm()
  6. getHHMMSS()
  7. getHHMMSS()
  8. getHHmmSS()
  9. getHourFormat(String string)