Java Date Format As formatDateMedium(Date date)

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

Description

format Date Medium

License

Open Source License

Declaration

public static String formatDateMedium(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.Calendar;
import java.util.Date;

public class Main {

    public static String formatDateMedium(Date date) {
        return DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);
    }//  w  ww . j  a  v a  2s.  c  o  m

    public static String format() {
        return toInfo(getCalendar());
    }

    /**
     * @param date
     */
    public static String toInfo(Date date) {
        return toInfo(date, "yyyy-MM-dd HH:mm:ss");
    }

    /**
     * @return
     */
    public static String toInfo() {
        return toInfo(getCalendar().getTime(), "yyyy-MM-dd");
    }

    /**
     * @param date
     * @param dateFromat
     */
    public static String toInfo(Date date, String dateFromat) {
        SimpleDateFormat format = new SimpleDateFormat(dateFromat);
        return format.format(date);
    }

    /**
     * @param calendar
     */
    public static String toInfo(Calendar calendar) {
        return toInfo(calendar.getTime());
    }

    public static Calendar getCalendar() {
        return Calendar.getInstance();
    }

    public static long getTime() {
        return getTime(getCalendar());
    }

    public static long getTime(Calendar c) {
        return c.getTimeInMillis();
    }
}

Related

  1. formatDateHeader(final Date date)
  2. formatDateHeader(final Date date)
  3. formatDateHMS(java.util.Date date)
  4. formatDateHMSMZ(Date date)
  5. formatDateList(List dateList)
  6. formatDatemhs(java.util.Date date)
  7. formatDateMonth(Date d)
  8. formatDateRfc822(Date date)
  9. formatDateStamp(final Date date)