Android Date Set time(Date date)

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

Description

time

Declaration

public static String time(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 time(Date date) {
        return format(date, "HH:mm");
    }/*from  w  w  w  .ja va2  s .  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. setTime(Date date, int hour, int minute, int second, int millisecond)
  2. setTime(Date date, int hours, int minutes)
  3. setTime(Date date, int hours, int minutes, int seconds)
  4. setYears(Date date, int amount)
  5. shortDate(Date date)
  6. toDateTime(Date date, Date time)
  7. offsetDate(Date date, int field, int offset)
  8. changeDate(String argDate)
  9. firstTimeOfDate(Date date)