Android Date Set shortDate(Date date)

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

Description

short Date

Declaration

public static String shortDate(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String shortDate(Date date) {
        return format(date, "MM-dd");
    }/*from ww w.jav a 2s. c o m*/

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

        DateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }

    public static String format(Date date) {
        return format(date, "yyyy-MM-dd HH:mm");
    }

    public static String format(Date date, boolean isDateOnly) {
        if (isDateOnly) {
            return date(date);
        } else {
            return format(date);
        }
    }

    public static String date(Date date) {
        return format(date, "yyyy-MM-dd");
    }
}

Related

  1. setSeconds(Date date, int amount)
  2. setTime(Date date, int hour, int minute, int second, int millisecond)
  3. setTime(Date date, int hours, int minutes)
  4. setTime(Date date, int hours, int minutes, int seconds)
  5. setYears(Date date, int amount)
  6. time(Date date)
  7. toDateTime(Date date, Date time)
  8. offsetDate(Date date, int field, int offset)
  9. changeDate(String argDate)