Java Date to String dateToHHmmStr(Date date)

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

Description

date To H Hmm Str

License

Open Source License

Declaration

public static String dateToHHmmStr(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String NORMAL_PATTERN = "yyyy-MM-dd HH:mm:ss";
    private static final String HH_MM_PATTERN = "HH:mm";

    public static String dateToHHmmStr(Date date) {
        return dateToString(date, HH_MM_PATTERN);
    }//from   w  ww  . j  av  a 2  s .  c  o  m

    public static String dateToString(Date date, String pattern) {
        if (date == null) {
            date = new Date();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }

    @Deprecated
    public static String dateToString(Date date) {
        return dateToStr(date);
    }

    public static String dateToStr(Date date) {
        if (date == null) {
            return "";
        }
        return dateToString(date, NORMAL_PATTERN);
    }

    public static String dateToStr() {
        return dateToStr(new Date());
    }
}

Related

  1. dateToDateString(Date date, Locale locale)
  2. dateToDDMMYYYYStr(Date dateTime)
  3. dateToDefaultDateString(Date date)
  4. dateToFMDate(Date date)
  5. dateToFormattedString(Date toFormat)
  6. dateToHMTime(Date date)
  7. dateToHttpDateString(Date d)
  8. dateToHuman(Date date)
  9. DateToInteger(Date date)