Java Hour Format formatTime(java.util.Date date)

Here you can find the source of formatTime(java.util.Date date)

Description

format Time

License

Open Source License

Declaration

public static String formatTime(java.util.Date date) 

Method Source Code

//package com.java2s;

public class Main {
    public static String formatTime(java.util.Date date) {
        if (date == null) {
            return "";
        }//from   w w  w  . ja  va2 s  .c o  m
        return format(date, "yyyy/MM/dd HH:mm:ss");

    }

    public static String format(java.util.Date date, String format) {
        String result = "";

        try {
            if (date != null) {
                java.text.DateFormat df = new java.text.SimpleDateFormat(format);

                result = df.format(date);

            }
        } catch (Exception e) {
        }
        return result;

    }

    public static String format(java.util.Date date) {
        if (date == null) {
            return "";
        }
        return format(date, "yyyy/MM/dd");

    }
}

Related

  1. formatTime(double s)
  2. formatTime(final Calendar cal)
  3. formatTime(final Date date)
  4. formatTime(final long time)
  5. formatTime(int msec, String format)
  6. formatTime(long aTime)
  7. formatTime(long ms)
  8. formatTime(long time)
  9. formatTime(long time)