Java Date Long Format getLongDateString(Date date)

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

Description

get Long Date String

License

Open Source License

Declaration

public static String getLongDateString(Date date) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String shortFormat = "yyyyMMdd";
    public final static String longFormat = "yyyyMMddHHmmss";

    public static String getLongDateString(Date date) {
        DateFormat dateFormat = new SimpleDateFormat(longFormat);

        return getDateString(date, dateFormat);
    }/*from ww  w  . j  a  va2  s .c o  m*/

    public static String getDateString(Date date, DateFormat dateFormat) {
        if (date == null || dateFormat == null) {
            return null;
        }

        return dateFormat.format(date);
    }

    public static String getDateString(Date date) {
        DateFormat df = getNewDateFormat(shortFormat);

        return df.format(date);
    }

    public static String format(Date date, String format) {
        if (date == null) {
            return null;
        }

        return new SimpleDateFormat(format).format(date);
    }

    public static DateFormat getNewDateFormat(String pattern) {
        DateFormat df = new SimpleDateFormat(pattern);

        df.setLenient(false);
        return df;
    }
}

Related

  1. getLongDateCurr()
  2. getLongDateFormat(Date d)
  3. getLongDateFormatter()
  4. getLongDateStr(Date sDate)
  5. getLongDateString(Date date)
  6. getLongDateString(Date date)
  7. getLongDateString(Date date, boolean includeTime)
  8. getLongDisplayDate(Date moment, TimeZone tz, Locale inLocale)
  9. getLongDisplayTime(long time)