Android Date to String Convert getShortFormat(Date date)

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

Description

get Short Format

Declaration

public static String getShortFormat(Date date) 

Method Source Code

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main{
    public static final String LOCAL_SHORT_DATE_FORMAT = "yyyy-MM-dd";
    public static String getShortFormat(Date date) {
        if (date == null) {
            return null;
        }/*  ww w  .  j  a va2 s . co m*/
        return getFormatString(date, LOCAL_SHORT_DATE_FORMAT);
    }
    public static String getFormatString(Date date, String dateFormat) {
        if (date == null || StringUtil.isEmpty(dateFormat)) {
            return null;
        }

        return new SimpleDateFormat(dateFormat, Locale.ENGLISH)
                .format(date);
    }
}

Related

  1. getFormatString(Date date, String dateFormat)
  2. getHourInFloat(Date date)
  3. getLongDateStr(Date date)
  4. getLongFormat(Date date)
  5. getShortDateTimeString(Date date)
  6. getStringFromDate(Date date)
  7. javaDateToIso8601(Date date)
  8. javaDateToTimeSpan(final Date date)
  9. toGMTDate(Date localDate)