Android Date Format formatDateAndTime(long millis)

Here you can find the source of formatDateAndTime(long millis)

Description

format Date And Time, "yyyy-MM-dd HH:mm"

Declaration

public static String formatDateAndTime(long millis) 

Method Source Code

//package com.java2s;

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

public class Main {
    private static final String FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";

    public static String formatDateAndTime(long millis) {
        if (millis == 0)
            return "";
        SimpleDateFormat sdf = new SimpleDateFormat(
                FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM);
        Date dt = new Date(millis);
        String sDateTime = null;//www. j  a  v  a  2 s  .  com

        sDateTime = sdf.format(dt);
        return sDateTime;
    }
}

Related

  1. formatDate(Date time)
  2. formatDate(SimpleDateFormat s, Date d)
  3. formatDate(String date)
  4. formatDate(long millis)
  5. formatDate1(String date)
  6. formatTM(Date d)
  7. fromString(String dateStr)
  8. fromString(String dateStr, String dateFormat)
  9. fromString(String dateStr, String dateFormat, Locale locale)