Java Date Format convertDateToHour(Date d)

Here you can find the source of convertDateToHour(Date d)

Description

convert Date To Hour

License

Apache License

Declaration

public static String convertDateToHour(Date d) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DateFormatSymbols;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String convertDateToHour(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("HH", new DateFormatSymbols());
        return df.format(d);
    }/*from  w  ww .j  a v  a 2 s  . c o  m*/

    /**
     * Returns a string the represents the passed-in date parsed according to
     * the passed-in format. Returns an empty string if the date or the format
     * is null.
     **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }
}

Related

  1. convertDateToBulgarianFormat(Date date)
  2. convertDateToCustomFormat(Date date, String datePattern)
  3. convertDateToDateString(Date date)
  4. convertDateToFileName(final Date datum)
  5. convertDateToGMTDateString(Date date)
  6. convertDateToISO8601(Date date)
  7. convertDateToMMDDYYYY(Date date)
  8. convertDateToRpcFormat(Date date)
  9. convertDateToString(Date aDate)