Java Date Long Format getLongFormatTime(java.util.Date date)

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

Description

get Long Format Time

License

Open Source License

Declaration

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

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String YYYY_MM_DD = "yyyy-MM-dd";

    public static String getLongFormatTime(java.util.Date date) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String strDate = df.format(date);
        return strDate;
    }//from w  w w.j  av  a 2 s . c o  m

    public static String format(Date date, String pattern) {
        if (date == null)
            return "";
        else
            return getFormatter(pattern).format(date);
    }

    public static String format(Date date) {
        if (date == null)
            return "";
        else
            return getFormatter(YYYY_MM_DD).format(date);
    }

    private static SimpleDateFormat getFormatter(String parttern) {
        return new SimpleDateFormat(parttern);
    }
}

Related

  1. getLongDateString(Date date)
  2. getLongDateString(Date date)
  3. getLongDateString(Date date, boolean includeTime)
  4. getLongDisplayDate(Date moment, TimeZone tz, Locale inLocale)
  5. getLongDisplayTime(long time)
  6. getLongFromDatestamp(String datestamp)
  7. getLongGmtDateString(Date date)
  8. getLongMillis(String date)
  9. getLongNowTime()